Skip to content

[renovziee] WEEK 03 Solutions #1778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 11, 2025
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
18 changes: 18 additions & 0 deletions combination-sum/renovizee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


// tag renovizee 3week
// https://github.com/DaleStudy/leetcode-study/issues/254
// https://leetcode.com/problems/valid-palindrome/ #39 #Medium
class Solution {
// Solv1 :
// 시간복잡도 : O(n)
// 공간복잡도 : O(n)
public List<List<Integer>> combinationSum(int[] candidates, int target) {

}
}

//-------------------------------------------------------------------------------------------------------------
// Java 문법 피드백
//
//-------------------------------------------------------------------------------------------------------------
18 changes: 18 additions & 0 deletions decode-ways/renovizee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


// tag renovizee 3week
// https://github.com/DaleStudy/leetcode-study/issues/268
// https://leetcode.com/problems/valid-palindrome/ #91 #Medium
class Solution {
// Solv1 :
// 시간복잡도 : O(n)
// 공간복잡도 : O(n)
public int numDecodings(String s) {

}
}

//-------------------------------------------------------------------------------------------------------------
// Java 문법 피드백
//
//-------------------------------------------------------------------------------------------------------------
18 changes: 18 additions & 0 deletions maximum-subarray/renovizee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


// tag renovizee 3week
// https://github.com/DaleStudy/leetcode-study/issues/275
// https://leetcode.com/problems/valid-palindrome/ #53 #Medium
class Solution {
// Solv1 :
// 시간복잡도 : O(n)
// 공간복잡도 : O(n)
public int maxSubArray(int[] nums) {

}
}

//-------------------------------------------------------------------------------------------------------------
// Java 문법 피드백
//
//-------------------------------------------------------------------------------------------------------------
45 changes: 45 additions & 0 deletions number-of-1-bits/renovizee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@


// tag renovizee 3week
// https://github.com/DaleStudy/leetcode-study/issues/232
// https://leetcode.com/problems/number-of-1-bits #191 #Easy
class Solution {
// Solv2 :
// 시간복잡도 : O(1)
// 공간복잡도 : O(1)
public int hammingWeight(int n) {
int result = 0;
for (int i = 0; i < 32; i++) {
if (((n >> i) & 1) == 1) {
result++;
}
}
return result;

}
// // Solv1 :
// // 시간복잡도 : O(log n)
// // 공간복잡도 : O(1)
// public int hammingWeight(int n) {
// int result = 0;
// int current = n;
// while (current >= 2) {
// if ((current % 2) == 1) {
// result++;
// }
// current = current / 2;
// }
// if (current == 1) {
// result++;
// }
// return result;
//
// }
}

//-------------------------------------------------------------------------------------------------------------
// Java 문법 피드백
// 1) String s=Integer.toBinaryString(n); 숫자를 이진수 string으로 변환하는 방법
// 2) 숫자를 비트 연산하는 방법 n >> i 는 정수 n을 i 만큼 오른쪽으로 shift 함, ex) 1011 -> 0101
// 3) & 은 비트에서 and 연산이고 & 1은 마지막 비트 검사로 특수하게 사용됨, 둘다 1인 경우만 1
//-------------------------------------------------------------------------------------------------------------
36 changes: 36 additions & 0 deletions valid-palindrome/renovizee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@


// tag renovizee 3week
// https://github.com/DaleStudy/leetcode-study/issues/220
// https://leetcode.com/problems/valid-palindrome/ #125 #Easy
class Solution {
// Solv1 :
// 시간복잡도 : O(n)
// 공간복잡도 : O(n)
public boolean isPalindrome(String s) {
// replaceAll(...): 문자열 전체를 한 번 순회 → O(n)
// trim(): 공백을 양쪽 끝에서만 탐색 → O(n) 이라고 보지만 보통 무시 가능한 수준
// toLowerCase(): 모든 문자를 소문자로 바꿈 → O(n)
String cleanString = s.replaceAll("[^a-zA-Z0-9]", "").trim().toLowerCase();

int left = 0;
int right = cleanString.length() - 1;

//O(n)
while (left < right) {
if (cleanString.charAt(left) != cleanString.charAt(right)) {
return false;
}
left++;
right--;
}
return true;

}
}

//-------------------------------------------------------------------------------------------------------------
// Java 문법 피드백
// 1) char[] 대문자 Char 가 아니고 소줌ㄴ자
// 2) ~.equals는 char에서 제공되지 않음
//-------------------------------------------------------------------------------------------------------------