File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
longest-palindromic-substring Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * μκ°λ³΅μ‘λ : O(n)
3+ * 곡κ°λ³΅μ‘λ : O(n)
4+ */
5+ public class kimjunyoung90 {
6+ public boolean isPalindrome (String s ) {
7+ //1. λλ¬Έμλ₯Ό μλ¬Έμλ‘ λ³ν
8+ s = s .toLowerCase ();
9+
10+ //2. μμ΄ μ«μ μΈ λ¬Έμ μ κ±°
11+ s = s .replaceAll ("[^a-z0-9]" , "" );
12+
13+ //3. μμμ μ½λ λ€μμ μ½λ λμΌνμ§ νμΈ(pointer μ¬μ©)
14+ int left = 0 , right = s .length () - 1 ;
15+ while (left < right ) {
16+ char leftChar = s .charAt (left );
17+ char rightChar = s .charAt (right );
18+ if (leftChar != rightChar ) return false ;
19+ left ++;
20+ right --;
21+ }
22+ return true ;
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ public class Solution {
2+ public int maxSubArray (int [] nums ) {
3+ int max = Integer .MIN_VALUE ;
4+ for (int i = 0 ; i < nums .length ; i ++) {
5+ for (int j = i ; j < nums .length ; j ++) {
6+ int sum = 0 ;
7+ for (int k = i ; k <= j ; k ++) {
8+ sum += nums [k ];
9+ }
10+ max = Math .max (max , sum );
11+ }
12+ }
13+ return max ;
14+ }
15+ }
You canβt perform that action at this time.
0 commit comments