leetcode submission 5 with test case