Two Pointer Leetcode Problems Sql Server