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.*; | |
public class AlienLanguage { | |
private static class Token { | |
Set<Character> validChars = new HashSet<Character>(); | |
public Token(String string) { | |
for(int i = 0; i < string.length(); 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
import java.util.*; | |
public class GeneratePalindrome { | |
public static List<String> palindromesOfLength(int N, Set<String> alphabet) { | |
List<String> result = new ArrayList<String>(); | |
if(N == 1) { | |
for(String letter : alphabet) { | |
result.add(letter); | |
} |
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.Scanner; | |
public class Yeehaa { | |
public double findr(double R, int N) { | |
double theta = Math.PI * 2 / N; | |
double b = Math.sqrt(R * R + R * R - 2 * R * R * Math.cos(theta)); | |
return b * R / (b + 2 * R); | |
} |
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.*; | |
public class DNASorting { | |
public static class DNA implements Comparable { | |
String dna; | |
public DNA(String str) { | |
dna = str; | |
} |
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
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <math.h> | |
using namespace std; | |
string longest_in_both(const string& s1, const string& s2) { | |
vector<vector<int> > dp; | |
for(int i = 0; i < s1.length(); i++) { | |
dp.push_back(vector<int>(s2.length(), -1)); |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |