Basic Algorithms For Leetcode 759