my algorithm in leetcode