Aven Financial interview question

leecode style question, but within a class