Just the algorithm in Leetcode