Recursion And Backtracking Leetcode Problems Javascript Substring