This file contains 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 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 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 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 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 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 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 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.*; | |
//2013 Facebook Hacker Cup Qualification Round | |
//Problem 3: Find the Min http://www.facebook.com/hackercup/problems.php?pid=494433657264959&round=185564241586420 | |
public class FindMin { | |
static Scanner in; | |
public static void main(String[] args) throws Exception { |
This file contains 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.*; | |
import static java.lang.Math.*; | |
//2013 Facebook Hacker Cup Qualification Round | |
//Problem 2: Balanced Smileys https://www.facebook.com/hackercup/problems.php?pid=403525256396727&round=185564241586420 | |
public class Balanced { | |
static Scanner in; |
This file contains 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.*; | |
//2013 Facebook Hacker Cup Qualification Round | |
//Problem 1: Beautiful strings https://www.facebook.com/hackercup/problems.php?pid=475986555798659&round=185564241586420 | |
public class Beautiful { | |
static Scanner in; | |
public static void main(String[] args) throws Exception { |