Passed small and large test cases on leetcode