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
| //http://coolcodebro.blogspot.com/2012/12/lognest-increasing-sequence-with-pairs.html | |
| //NOTE: Use some kind of dynamic programming if data is too big | |
| public class Circus { | |
| public static void main(String[] args) { | |
| new Circus().run(); | |
| } | |
| void run() { |
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
| //http://coolcodebro.blogspot.com/2012/12/swap-number-in-place.html | |
| void run() { | |
| swap(10, 25); | |
| } | |
| void swap(int a, int b) { | |
| if(a > b) | |
| swapM(a, 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
| //http://coolcodebro.blogspot.com/2012/12/find-index-in-array-such-that-ai-i.html | |
| void run() { | |
| int[] arr = {-3, -1, 0, 1, 2, 4, 6, 9}; | |
| System.out.printf("Magic index: %d%n", getMagicIndex(arr)); | |
| } | |
| int getMagicIndex(int[] arr) { | |
| if(arr.length == 0) | |
| return -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
| //Function to get all possible substrings of a string | |
| List<String> getAllSubstrings(String str) { | |
| assert(str != null && str.length() > 0); | |
| if(str.length() == 1){ | |
| List<String> substrings = new ArrayList<String>(); | |
| substrings.add(str); | |
| return substrings; | |
| } |
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
| 36 | |
| 3 7 | |
| 4 7 | |
| 5 7 | |
| 3 4 | |
| 4 4 | |
| 5 4 | |
| 5 3 | |
| 5 2 | |
| 3 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
| 99 | |
| Anna | |
| aToyota | |
| sonor | |
| Union | |
| University | |
| man | |
| woman | |
| palindrome | |
| poor |
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
| 3 | |
| 09:00-09:50 | |
| 13:00-17:00 | |
| 09:50-10:30 | |
| 2 | |
| 10:00-11:00 | |
| 09:00-12:00 | |
| 1 | |
| 00:00-23:59 | |
| 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
| 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 { |
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.*; | |
| 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 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.*; | |
| //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 { |