8000 修复可能越界的bug · ddphit/leetcode@86ecfee · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 86ecfee

Browse files
committed
修复可能越界的bug
1 parent ebb384b commit 86ecfee

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

C++/chapDFS.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ \subsubsection{深搜1}
6363
}
6464

6565
bool isPalindrome(const string &s, int start, int end) {
66-
while (s[start] == s[end]) {
66+
while (start < end && s[start] == s[end]) {
6767
++start;
6868
--end;
6969
}
@@ -101,7 +101,7 @@ \subsubsection{深搜2}
101101
}
102102
}
103103
bool isPalindrome(const string &s, int start, int end) {
104-
while (s[start] == s[end]) {
104+
while (start < end && s[start] == s[end]) {
105105
++start;
106106
--end;
107107
}

0 commit comments

Comments
 (0)
0