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
22 changes: 22 additions & 0 deletions palindromic-substrings/s0ooo0k.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Solution {
// 팰린드롬의 경우 양쪽이 같아야 하므로, 중심을 잡고 left, right로 늘려나가는 방식
public int countSubstrings(String s) {
int cnt = 0;

for(int i=0; i<s.length(); i++) {
cnt += palindrome(s, i, i);
cnt += palindrome(s, i, i+1);
}
return cnt;
}
public static int palindrome(final String s, int left, int right) {
int cnt = 0;
while(left>=0 && right < s.length() && s.charAt(left)==s.charAt(right)) {
cnt++;
left--;
right++;
}
return cnt;
}
}

12 changes: 12 additions & 0 deletions reverse-bits/s0ooo0k.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution {
public int reverseBits(int n) {
int result = 0;
for(int i = 0; i < 32; i++) {
result <<= 1;
result |= (n & 1);
n >>>= 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

배워갑니다 ㅎㅎ 코드가 깔끔하시네요

}
return result;
}
}