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 PiecewiseLinearFunctionDiv2 { | |
public int[] countSolutions(int[] Y, int[] query) { | |
int[] ans = new int[query.length]; | |
for (int q = 0; q < query.length; q++) { | |
int n = 0; | |
if (query[q] == Y[Y.length-1]) { | |
n++; | |
} | |
for (int y = 0; y < Y.length-1; y++) { |
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 InsertZ { | |
public String canTransform(String init, String goal) { | |
String ansString = goal.replaceAll("z", ""); | |
if (ansString.equals(init)) { | |
return "Yes"; | |
} | |
return "No"; | |
} |
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 KeyDungeonDiv2 { | |
public int countDoors(int[] doorR, int[] doorG, int[] keys) { | |
int open = 0; | |
for (int i = 0; i < doorR.length; i++) { | |
int r = doorR[i]; | |
int g = doorG[i]; | |
int w = keys[2]; | |
r = r - keys[0]; | |
g = g - keys[1]; |
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
System.out.println(Arrays.toString(array)); |
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 FoxAndClassroom { | |
public String ableTo(int n, int m) { | |
boolean[][] seated = new boolean[n][]; | |
for (int i = 0; i < seated.length; i++) { | |
seated[i] = new boolean[m]; | |
} | |
int r = 0; | |
int c = 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
import java.util.HashSet; | |
public class AstronomicalRecordsEasy { | |
public int minimalPlanets(int[] A, int[] B) { | |
int min = A.length + B.length - 1; | |
for (int a : A) { | |
for (int b : B) { | |
HashSet<Integer> set = new HashSet<Integer>(); |
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.HashSet; | |
public class AstronomicalRecordsEasyBaka { | |
public int minimalPlanets(int[] A, int[] B) { | |
int min = A.length + B.length - 1; | |
for (int a = 1; a <= 1000; a++) { | |
for (int b = 1; b <= 1000; b++) { | |
if (a % 2 == 0 && b % 2 == 0) { | |
continue; |
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 BlackAndWhiteSolitaire { | |
public int minimumTurns(String cardFront) { | |
String[] candidate = new String[] { "", "" }; | |
for (int i = 0; i < cardFront.length(); i++) { | |
if (i % 2 == 0) { | |
candidate[0] += "W"; | |
candidate[1] += "B"; | |
} else { |
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
/*__SRM593 div2 500__*/ | |
import java.util.ArrayList; | |
import java.util.List; | |
public class WolfDelaymaster { | |
public String check(String str) { | |
String wolf = "wolf"; | |
List<String> validWordsList = new ArrayList<String>(); |
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
/*__SRM587 Div2 500__*/ | |
public class JumpFurther { | |
public int furthest(int N, int badStep) { | |
int step = 0; | |
for (int i = 1; i <= N; i++) { | |
step += i; | |
if (step == badStep) { | |
step--; | |
} |