Netwealth Investments interview question

Leetcode easy level programming question, be prepared to explain the time complexity of your solution