Attempting to solve square subsequences problem on HackerRank