6
var numberOfArrays = function (s, k) {8
return backtrack(0) % 1000000007;9
function backtrack(pos) {11
if (cache[pos] !== undefined) {16
while (pos < s.length) {17
digit = digit * 10 + parseInt(s[pos]);18
if (digit <= k && pos + 1 <= s.length - 1 && s[pos + 1] !== "0") {19
//If we can call backtrack on next position.20
count += backtrack(pos + 1) % 1000000007;27
if (pos === s.length && digit <= k) {28
//If this number became the only digit in the array, for string starting at position orignalPos. This also completed the etire string.31
cache[orignalPos] = count;