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
// ch 8.7 | |
import java.util.*; | |
public class Main { | |
public static void main(String args[]) { | |
System.out.println(getPerms("ab")); // [ab, ba] | |
System.out.println(getPerms("abc")); // [abc, acb, bac, bca, cab, cba] | |
System.out.println(getPerms("love")); // [love, loev, lvoe, lveo, leov, levo, olve, olev, ovle, ovel, oelv, oevl, vloe, vleo, vole, voel, velo, veol, elov, elvo, eolv, eovl, evlo, evol] | |
} | |
static ArrayList < String > getPerms(String input) { |
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.io.*; | |
import java.util.*; | |
public class Solution { | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
int T = in.nextInt(); | |
for (int t = 1; t <= T; t++) { | |
int n = 0; | |
System.out.printf("Case #%d: %d\n", t, n); |
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
/** | |
There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following requirements: | |
1. Each child must have at least one candy. | |
2. Children with a higher rating get more candies than their neighbors. | |
What is the minimum candies you must give? | |
*/ | |
import java.util.*; | |
public int candy(int[] ratings) { | |
int N = ratings.length; |
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
// Round F | |
// Flattening | |
import java.io.*; | |
import java.util.*; | |
public class Solution { | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
int T = in.nextInt(); | |
for (int t = 1; t <= T; t++) { |
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 { | |
private boolean isDigit(String s) { | |
return s.matches("\\d"); | |
} | |
private String generate(String unit, int times) { | |
StringBuilder sb = new StringBuilder(); | |
while (times > 0) { | |
sb.append(unit); | |
times--; |
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
alias co="cd ~/code" | |
B="\e[38;5;35m" | |
C="\e[38;5;50m" | |
D="\e[38;5;199m" | |
E="\[\033[00m\]" | |
b() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
s() { |