LeetCode solution with C#