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
| //NOTE: did not test AT ALL | |
| //Time: O(N*k), k = length of the longest word in the sentence | |
| //Space: O(1) | |
| public class Reversed { | |
| public static void main(String[] args) { | |
| String sent = "Coding for Interviews contains too many gifs."; | |
| reverse(sent); | |
| } | |
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.*; | |
| import java.io.*; | |
| public class C1 { | |
| public static void main(String[] args) throws Exception { | |
| Scanner in = new Scanner(new File("c1.in")); | |
| int[] palin = {1, 4, 9, 121, 484}; | |
| int t = in.nextInt(); | |
| for(int i=1; i<=t; 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.*; | |
| import java.io.*; | |
| public class C2 { | |
| static Scanner in; | |
| static BufferedWriter out; | |
| long[] palin = new long[40]; | |
| public static void main(String[] args) throws Exception { | |
| in = new Scanner(new File("c2.in")); |
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
| // Twitter Codibility Screening | |
| public class Two { | |
| public int solution(int[] A) { | |
| int evens = getEvensCount(A); | |
| long totalPairs = nChooseK(evens, 2) + nChooseK(A.length - evens, 2); | |
| return totalPairs > 1000000000 ? -1 : (int) totalPairs; | |
| } |
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.*; | |
| import static java.lang.Math.min; | |
| public class Main { | |
| public static void main(String[] args) { | |
| Scanner in = new Scanner(System.in); | |
| int distance = in.nextInt(), n = in.nextInt(); | |
| int[] costs = new int[distance + 1]; | |
| Arrays.fill(costs, Integer.MAX_VALUE / 2); |
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.*; | |
| import java.util.Map.Entry; | |
| import java.util.AbstractMap.SimpleEntry; | |
| import static java.lang.Integer.*; | |
| import static java.lang.Math.min; | |
| public class Main { | |
| static class Vertex implements Comparable<Vertex> { | |
| int id, distance = MAX_VALUE; |
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
| #!/usr/bin/env python3 | |
| '''Ruzzle Solver | |
| __author__ = 'github.com/Bekt' | |
| __date__ = 3/22/2014 | |
| ''' | |
| import sys | |
| from collections import defaultdict |
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
| #!/usr/bin/env python3 | |
| ''' Problem A: Magic Trick https://code.google.com/codejam/contest/2974486/dashboard#s=p0 ''' | |
| def get_int(): | |
| return int(input()) | |
| def solve(): | |
| choice1 = get_int() - 1 | |
| arr1 = [set(input().split()) for x in range(4)] |
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
| #!/usr/bin/env python3 | |
| '''Problem B: Cookie Clicker Alpha https://code.google.com/codejam/contest/2974486/dashboard#s=p1''' | |
| def solve(c, f, x): | |
| rate, total = 2.0, 0 | |
| m = x / rate | |
| while m <= x: | |
| total += (c / rate) | |
| rate += f |
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
| # This is a Git cheat-sheet for beginners. | |
| # 1. Initial clone | |
| git clone <package name> | |
| # 2. Checkout a new branch | |
| git checkout -b <feature> | |
| # 3. Make changes | |
| echo "Hack hack hack" >> newfile.txt |