Chatham Financial interview question

Simple Leetcode problem that can be solved