diff --git a/palindromic-substrings/whewchews.ts b/palindromic-substrings/whewchews.ts index 294c721f4..fa9e302f1 100644 --- a/palindromic-substrings/whewchews.ts +++ b/palindromic-substrings/whewchews.ts @@ -4,8 +4,8 @@ function countSubstrings(s: string): number { const n = s.length; // TC: O(N^2) - for (let start = 0; start < n; start++) { - for (let end = start; end >= 0; end--) { + for (let start = n; start >= 0; start--) { + for (let end = start; end < n; end++) { if (start === end) { dict.set(`${start}:${end}`, true); } else if (start + 1 === end) {