Leetcode coding exercise