I just tried out this problem on Leetcode last night! I thought about introducing an object to solve it but never got around to trying it out. I really like your solution though! Great job, Claire!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.