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
19 changes: 19 additions & 0 deletions 3sum/renovizee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.List;


// tag renovizee 2week unresolved
// https://github.com/DaleStudy/leetcode-study/issues/241
// https://leetcode.com/problems/3sum/
class Solution {
// Solv1 :
// 시간복잡도 : O(n)
// 공간복잡도 : O(n)
public List<List<Integer>> threeSum(int[] nums) {

}
}

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



// tag renovizee 2week
// https://github.com/DaleStudy/leetcode-study/issues/230
// https://leetcode.com/problems/climbing-stairs/ #70 #Easy
class Solution {
// Solv1
// 시간복잡도 : O(n)
// 공간복잡도 : O(n)
public int climbStairs(int n) {
int[] dp = new int[]{1, 2};

if (n == dp[0]) {
return dp[0];
}

if (n == dp[1]) {
return dp[1];
}

for (int i = 3; i <= n; i++) {
int nextWayCount = dp[0] + dp[1];
dp[0] = dp[1];
dp[1] = nextWayCount;
}

return dp[1];

}
}
//-------------------------------------------------------------------------------------------------------------
// Java 문법 피드백
// 1) Math.pow(2, 3) 2의 3승.
//-------------------------------------------------------------------------------------------------------------
2 changes: 2 additions & 0 deletions house-robber/renovizee.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

// tag renovizee 1week unresolved
// https://github.com/DaleStudy/leetcode-study/issues/264
// https://leetcode.com/problems/house-robber/
// DP 자체에 대한 설명 : https://www.youtube.com/watch?v=0bqfTzpWySY
class Solution {
public int rob(int[] nums) {

Expand Down
49 changes: 49 additions & 0 deletions product-of-array-except-self/renovizee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@


// tag renovizee 2week
// https://github.com/DaleStudy/leetcode-study/issues/239
// https://leetcode.com/problems/product-of-array-except-self/ #238 #Medium
class Solution {
// Solv1 :
// 시간복잡도 : O(n)
// 공간복잡도 : O(n)
public int[] productExceptSelf(int[] nums) {

boolean isZero = false;
int zeroIndex = 0;

int productExceptZero = 1;
for (int i = 0; i < nums.length; i++) {
if (nums[i] == 0) {
if (isZero) { // zero가 2개면 모든 원소가 0임.
return new int[nums.length];
}
zeroIndex = i;
isZero = true;
} else {
productExceptZero *= nums[i];
}
}

int[] result = new int[nums.length];
for (int i = 0; i < nums.length; i++) {
if (isZero) {
if (i != zeroIndex) {
result[i] = 0;
} else {
result[i] = productExceptZero;
}
} else {
result[i] = productExceptZero / nums[i];
}

}
return result;
}

}

//-------------------------------------------------------------------------------------------------------------
// Java 문법 피드백
//
//-------------------------------------------------------------------------------------------------------------
2 changes: 2 additions & 0 deletions top-k-frequent-elements/renovizee.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

// tag renovizee 1week unresolved
// https://github.com/DaleStudy/leetcode-study/issues/237
// https://leetcode.com/problems/top-k-frequent-elements/
class Solution {

public int[] topKFrequent(int[] nums, int k) {
int[] result = {1, 2, 3};

Expand Down
27 changes: 27 additions & 0 deletions valid-anagram/renovizee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import java.util.Arrays;

// tag renovizee 2week
// https://github.com/DaleStudy/leetcode-study/issues/218
// https://leetcode.com/problems/valid-anagram/ #242 #Easy
class Solution {
// Solv1
// 시간복잡도 : O(n)
// 공간복잡도 : O(n)
public boolean isAnagram(String s, String t) {

char[] sChars = s.toCharArray();
char[] tChars = t.toCharArray();

Arrays.sort(sChars);
Arrays.sort(tChars);

return Arrays.equals(sChars, tChars);
}
}

//-------------------------------------------------------------------------------------------------------------
// Java 문법 피드백
// 1) string.toCharArray
// 2) Arrays.~ 문법 ~.sort ~.equals
// 3) Arrays.
//-------------------------------------------------------------------------------------------------------------
35 changes: 35 additions & 0 deletions validate-binary-search-tree/renovizee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@


// tag renovizee 2week
// https://github.com/DaleStudy/leetcode-study/issues/251
// https://leetcode.com/problems/validate-binary-search-tree/
class Solution {

/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode() {}
* TreeNode(int val) { this.val = val; }
* TreeNode(int val, TreeNode left, TreeNode right) {
* this.val = val;
* this.left = left;
* this.right = right;
* }
* }
*/

// Solv1 :
// 시간복잡도 : O(n)
// 공간복잡도 : O(n)
public boolean isValidBST(TreeNode root) {

}
}

//-------------------------------------------------------------------------------------------------------------
// Java 문법 피드백
//
//-------------------------------------------------------------------------------------------------------------