solution of leetcode.com