Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions longest-palindromic-substring/kimjunyoung90.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* 시간복잡도 : O(n)
* 공간복잡도 : O(n)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공간복잡도는 O(1)인 것 같습니다!

*/
public class kimjunyoung90 {
public boolean isPalindrome(String s) {
//1. 대문자를 소문자로 변환
s = s.toLowerCase();

//2. 영어 숫자 외 문자 제거
s = s.replaceAll("[^a-z0-9]", "");

//3. 앞에서 읽나 뒤에서 읽나 동일한지 확인(pointer 사용)
int left = 0, right = s.length() - 1;
while(left < right) {
char leftChar = s.charAt(left);
char rightChar = s.charAt(right);
if(leftChar != rightChar) return false;
left++;
right--;
}
return true;
}
}
15 changes: 15 additions & 0 deletions maximum-subarray/kimjunyoung90.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Solution {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

시간/공간 복잡도에 대한 주석이 추가되면 좋을 것 같습니다!

public int maxSubArray(int[] nums) {
int max = Integer.MIN_VALUE;
for(int i = 0; i < nums.length; i++) {
for (int j = i; j < nums.length; j++) {
int sum = 0;
for(int k = i; k <= j; k++) {
sum+= nums[k];
}
max = Math.max(max, sum);
}
}
return max;
}
}