leetcode submission 10 with test case