speedfirst' leetcode solution