BNY interview question

(OA) Two medium/hard problems on hackerrank