File tree Expand file tree Collapse file tree 1 file changed +26
-26
lines changed Expand file tree Collapse file tree 1 file changed +26
-26
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ start = start + 1;
89
89
end = start + max. length();
90
90
```
91
91
92
- end 를 ` start + max.length() ` 로 두어 연산을 많이 줄일 수 있었고 꽤 큰 차이가 발생된다.
92
+ 다음 end 값을 ` start + max.length() ` 로 두어 연산을 많이 줄일 수 있었고 꽤 큰 차이가 발생된다.
93
93
94
94
``` java
95
95
class Solution {
@@ -170,31 +170,31 @@ class Solution {
170
170
``` java
171
171
class Solution {
172
172
public String longestPalindrome (String s ) {
173
- String max = " " ;
174
-
175
- char [] charArray = s. toCharArray();
176
- for (int i = 0 ; i < s. length(); i++ ) {
177
- char currentChar = charArray[i];
178
- int left = i;
179
- int right = i;
180
-
181
- while (right < s. length() - 1 && currentChar == charArray[right + 1 ]) {
182
- right++ ;
183
- }
184
-
185
- while (left > 0 && right < s. length() - 1 && charArray[left - 1 ] == charArray[right + 1 ]) {
186
- left-- ;
187
- right++ ;
188
- }
189
-
190
- String temp = s. substring(left, right + 1 );
191
- if (temp. length() > max. length()) {
192
- max = temp;
193
- }
194
- }
195
-
196
- return max;
197
- }
173
+ String max = " " ;
174
+
175
+ char [] charArray = s. toCharArray();
176
+ for (int i = 0 ; i < s. length(); i++ ) {
177
+ char currentChar = charArray[i];
178
+ int left = i;
179
+ int right = i;
180
+
181
+ while (right < s. length() - 1 && currentChar == charArray[right + 1 ]) {
182
+ right++ ;
183
+ }
184
+
185
+ while (left > 0 && right < s. length() - 1 && charArray[left - 1 ] == charArray[right + 1 ]) {
186
+ left-- ;
187
+ right++ ;
188
+ }
189
+
190
+ String temp = s. substring(left, right + 1 );
191
+ if (temp. length() > max. length()) {
192
+ max = temp;
193
+ }
194
+ }
195
+
196
+ return max;
197
+ }
198
198
}
199
199
```
200
200
You can’t perform that action at this time.
0 commit comments