LeetCode excercise