Point72 Interview Question

Easy hackerrank question made harder by requiring linear time complexity