Skip to content

Commit

Permalink
Fix: reverse loop direction to check palindrome
Browse files Browse the repository at this point in the history
Co-authored-by: Dale Seo <[email protected]>
  • Loading branch information
whewchews and DaleSeo authored Aug 17, 2024
1 parent 34a18cd commit 5bd7b75
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions palindromic-substrings/whewchews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5bd7b75

Please sign in to comment.