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 leetcode2/1easy/최원준/Q3498.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package Leetcode.최원준;

/*
1. 아이디어 :
-

2. 시간복잡도 :
O( n )

3. 자료구조/알고리즘 :
- / -
*/

public class Q3498 {
class Solution {
public int reverseDegree(String s) {
int n = s.length(), ans = 0;
for (int i=0; i<n; i++) {
ans += (i+1) * (26 - (s.charAt(i) - 'a'));
}
return ans;
}
}
}
37 changes: 37 additions & 0 deletions leetcode2/2medium/최원준/Q2208.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package Leetcode.최원준;

/*
1. 아이디어 :
우선순위큐을 이용해서 가장 큰 값을 반으로 줄이는 작업을 반복

2. 시간복잡도 :
O( nlogn )

3. 자료구조/알고리즘 :
우선순위 큐 / -
*/

import java.util.PriorityQueue;

public class Q2208 {
class Solution {
public int halveArray(int[] nums) {
int n = nums.length, ans = 0;
double total = 0.0;
PriorityQueue<Double> pq = new PriorityQueue<>((a, b) -> Double.compare(b,a));
for (int num : nums) {
total += num;
pq.add(num + 0.0);
}

double target = total / 2;
while (total > target) {
ans++;
double halfed = pq.poll()/2;
total -= halfed;
pq.add(halfed);
}
return ans;
}
}
}
40 changes: 40 additions & 0 deletions leetcode2/3hard/최원준/Q1220.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package Leetcode.최원준;

/*
1. 아이디어 :
dp 문제

2. 시간복잡도 :
O( 5 * n )

3. 자료구조/알고리즘 :
2차원 배열 / dp
*/

public class Q1220 {
class Solution {
int MOD = 1_000_000_007;
public int countVowelPermutation(int n) {
/*
1. e a
2. a,i e
3. i not i
4. i,u o
5. u a
*/
long[][] dp = new long[n+1][5];
dp[1] = new long[]{1, 1, 1, 1, 1}; // a e i o u

for (int i=2; i<n+1; i++) {
dp[i][0] = (dp[i-1][1]) % MOD;
dp[i][1] = (dp[i-1][0] % MOD + dp[i-1][2] % MOD) % MOD;
dp[i][2] = (dp[i-1][0] % MOD + dp[i-1][1] % MOD + dp[i-1][3] % MOD + dp[i-1][4] % MOD) % MOD;
dp[i][3] = (dp[i-1][2] % MOD + dp[i-1][4] % MOD) % MOD;
dp[i][4] = (dp[i-1][0]) % MOD;
}
long ans = 0;
for (int i=0; i<5; i++) ans = (ans + dp[n][i]) % MOD;
return (int)ans;
}
}
}