Skip to content

Instantly share code, notes, and snippets.

@varzan
varzan / CardGame.java
Last active December 13, 2015 19:59
Facebook Hacker Cup 2013, Round 1, Problem 1. Exercise from http://programmingpraxis.com/2013/02/15/facebook-hacker-cup-2013-round-1-problem-1
package cardgame;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;
/**
* This class solves the card game problem from Facebook Hacker Cup 2013 round
* 1. http://programmingpraxis.com/2013/02/15/facebook-hacker-cup-2013-round-1-
/*
* Exercise from http://programmingpraxis.com/2012/11/27/amazon-interview-question/
* Given a million points (x, y), give an O(n) solution to find the 100 points closest to (0, 0).
* Well, you have to read "a million" as "n" and "100" as "100".
* Uses a heap of size 100. The complexity-theoretic trick is that 100 is a constant here.
*/
import java.io.File;
import java.io.FileNotFoundException;
import java.util.PriorityQueue;