This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Coin { | |
public static int solution(int sum, int[] coins){ | |
int[] dp = new int[sum + 1]; | |
dp[0] = 1; | |
for (int i = 0; i < coins.length; i++) { | |
for (int j = 1; j <= sum; j++) { | |
if (j >= coins[i]) | |
dp[j] += dp[j - coins[i]]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class Solution | |
{ | |
public int solution(int [][]board) | |
{ | |
int answer = 0; | |
answer = Arrays.stream(board).flatMapToInt(Arrays::stream).max().getAsInt(); | |
if(answer == 0){ | |
return 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public static int[] answer; | |
public int[] solution(int[][] arr) { | |
answer = new int[2]; | |
divide(arr, 0, 0, arr.length); | |
return answer; | |
} | |
public static void divide(int[][] arr, int a, int b, int size){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class Solution { | |
public int[] solution(String[] keymap, String[] targets) { | |
int[] answer = new int[targets.length]; | |
HashMap<Character, Integer> keypad = new HashMap<>(); | |
for (int i = 0; i < keymap.length; i++) { | |
for (int j = 0; j < keymap[i].length(); j++) { | |
char cur = keymap[i].charAt(j); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public int solution(String skill, String[] skill_trees) { | |
int answer = 0; | |
for (int i = 0; i < skill_trees.length; i++) { | |
skill_trees[i] = skill_trees[i].replaceAll("[^"+skill+"]",""); | |
boolean flag = false; | |
for (int j = 0; j < skill_trees[i].length(); j++) { | |
if(skill.charAt(j) != skill_trees[i].charAt(j)){ | |
flag = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Comparator; | |
import java.util.HashMap; | |
public class Solution { | |
public static class movie{ | |
int idx; | |
int play; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class Solution { | |
boolean solution(String s) { | |
boolean answer = true; | |
Stack<Character> stack = new Stack<>(); | |
for(char item : s.toCharArray()){ | |
if(item == '('){ | |
stack.push('('); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class Solution { | |
public int[] solution(String msg) { | |
HashMap<String, Integer> map = new HashMap<>(); | |
for (int i = 0; i < 26; i++) { | |
map.put(String.valueOf((char) ('A' + i)), i + 1); | |
} | |
ArrayList<Integer> result = new ArrayList<>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class Solution { | |
public String solution(String s, String skip, int index) { | |
ArrayList<Character> list = new ArrayList<>(); | |
for(int i = 0; i < 26; i++){ | |
list.add((char) ('a' + i)); | |
} | |
for(Character item : skip.toCharArray()){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class Solution { | |
public int[] solution(String[] name, int[] yearning, String[][] photo) { | |
int[] answer = new int[photo.length]; | |
HashMap<String, Integer> nameMap = new HashMap<>(); | |
for(int i = 0; i < name.length; i++){ | |
nameMap.put(name[i], yearning[i]); | |
} |
NewerOlder