반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- Mock vs Stub
- TypeScript
- nuxtjs/composition-api buildModules
- frontend
- DI
- mock stub
- docker desktop 대체
- Spock Mock Stub Spy
- 트랜잭션 격리
- Docker Desktop 쓰고싶다
- mock stub spy
- Spock Spy
- webpack
- vue store
- HTTP란
- enum
- Rancher Desktop설치
- Javascript
- ECMAScript
- Spock Mock
- Spock Stub
- TCP/IP
- Vue+Typescript
- 공짜로 Docker Desktop같은거 쓰기
- 타입스크립트
- 자바스크립트
- docker desktop 유료화 정책
- @Transaction propagation
- 의존성주입
- @Transaction isolation
Archives
- Today
- Total
끄적끄적
[알고리즘] Longest Palindromic Substring (java) 본문
반응형
class Solution {
public String longestPalindrome(String s) {
if (s == null || "".equals(s)) {
return s;
}
int len = s.length();
int max = 0;
String answer = "";
boolean[][] dp = new boolean[len][len];
for (int j = 0; j < len; j++) {
for (int i = 0; i <= j; i++) {
boolean judge = s.charAt(i) == s.charAt(j);
dp[i][j] = j - i > 2 ? dp[i + 1][j - 1] && judge : judge;
if (dp[i][j] && j - i + 1 > max) {
max = j - i + 1;
answer = s.substring(i, j + 1);
}
}
}
return answer;
}
}
Runtime - 333 ms
Memory - 65.8 MB
반응형
' Computer Science > Algorithm' 카테고리의 다른 글
[알고리즘] Palindrome Number(java) (0) | 2020.04.25 |
---|---|
[알고리즘] Reverse Integer(java) (0) | 2020.04.25 |
[알고리즘] Two Sum(java, javascript) (0) | 2020.04.25 |
Comments