Shortest Common Subsequence Leetcode Problems Javascript For Loop