Bloomberg Interview Question

I was asked simple algorithm problems taken from LeetCode(first: easy level, second: medium level)