Skip to content

Instantly share code, notes, and snippets.

View Bekt's full-sized avatar
👨‍🍳
making things happen

Kanat Bekt Bekt

👨‍🍳
making things happen
View GitHub Profile
@Bekt
Bekt / Circus.java
Last active December 10, 2015 03:38
//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() {
//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
//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;
//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;
}
@Bekt
Bekt / golf.in
Last active December 11, 2015 04:59
36
3 7
4 7
5 7
3 4
4 4
5 4
5 3
5 2
3 1
99
Anna
aToyota
sonor
Union
University
man
woman
palindrome
poor
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
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 {
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;
@Bekt
Bekt / FindMin.java
Last active December 11, 2015 21:18
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 {