Shortest Common Subsequence Leetcode Problems Javascript Function