All test cases passed, but memory limit exceeded. I am using JavaScript. What happened?

My code:

```
let isSubsequence = function (s, t) {
let set = [];
for (let i = 0; i < t.length; i++) {
if (set[t.charCodeAt(i) - 97]) set[t.charCodeAt(i) - 97].push(i);
else set[t.charCodeAt(i) - 97] = [i];
}
let prevIndex = -1;
for (let i = 0; i < s.length; i++) {
let j = set[s.charCodeAt(i) - 97];
if (!j) return false;
let index = binarySearch(j, prevIndex);
if (index === j.length) return false;
else prevIndex = j[index];
}
return true;
};
//Find the index to insert num.
function binarySearch(nums, num) {
if (num < nums[0]) {
return 0;
} else if (num >= nums[nums.length - 1]) {
return nums.length;
} else {
let left = 0, right = nums.length - 1;
while (left + 1 < right) {
let mid = Math.floor((left + right) / 2);
if (nums[mid] > num) right = mid;
else left = mid;
}
return right;
}
}
```