diff --git a/combination-sum/renovizee.java b/combination-sum/renovizee.java new file mode 100644 index 000000000..bd61a5e24 --- /dev/null +++ b/combination-sum/renovizee.java @@ -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> combinationSum(int[] candidates, int target) { + + } +} + +//------------------------------------------------------------------------------------------------------------- +// Java 문법 피드백 +// +//------------------------------------------------------------------------------------------------------------- diff --git a/decode-ways/renovizee.java b/decode-ways/renovizee.java new file mode 100644 index 000000000..abe02623e --- /dev/null +++ b/decode-ways/renovizee.java @@ -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 문법 피드백 +// +//------------------------------------------------------------------------------------------------------------- diff --git a/maximum-subarray/renovizee.java b/maximum-subarray/renovizee.java new file mode 100644 index 000000000..ab522e3f2 --- /dev/null +++ b/maximum-subarray/renovizee.java @@ -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 문법 피드백 +// +//------------------------------------------------------------------------------------------------------------- diff --git a/number-of-1-bits/renovizee.java b/number-of-1-bits/renovizee.java new file mode 100644 index 000000000..22de6f39c --- /dev/null +++ b/number-of-1-bits/renovizee.java @@ -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 +//------------------------------------------------------------------------------------------------------------- diff --git a/valid-palindrome/renovizee.java b/valid-palindrome/renovizee.java new file mode 100644 index 000000000..d0ffc402b --- /dev/null +++ b/valid-palindrome/renovizee.java @@ -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에서 제공되지 않음 +//-------------------------------------------------------------------------------------------------------------