Skip to content

Instantly share code, notes, and snippets.

View phaniram's full-sized avatar

Maturu Srinivas Phani Ram phaniram

View GitHub Profile
@phaniram
phaniram / Solution.java
Created December 28, 2011 18:28
Interview Street Challenges-String reduction
package interviewstreet;
import java.util.Arrays;
import java.util.Scanner;
public class Solution {
int min=1;
int val=1;
public static void main(String[] args) {
@phaniram
phaniram / Topfive.java
Created December 28, 2011 18:31
Gild.com puzzle - Topfive
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
class Topfive {
@phaniram
phaniram / Fightsopa.java
Created December 29, 2011 00:43
Gild.com puzzle - Fightsopa
package com.gild.puzzles;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;
public class Fightsopa {
public void process(String input,int n)
@phaniram
phaniram / Solution.java
Created December 29, 2011 22:41
Interview Street Challenges - String similarity
package com.interviewstreet.puzzles;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scanner;
Solution sr = new Solution();
scanner = new Scanner(System.in);
int no_cases = scanner.nextInt();
for (int i = 0; i < no_cases; i++) {
@phaniram
phaniram / solve.rb
Created December 30, 2011 00:09
Interview Street Challenges - String similarity
def solve(str)
ary = str.split("")
len = ary.length
total = 0
for i in 1..(len-1)
count = 0
for j in i..(len-1)
if ary[j - i] != ary[j] then
break
end
@phaniram
phaniram / Quad_query.java
Created January 3, 2012 10:30
Interview Street Challenges - Quadrant queries
package com.interviewstreet.puzzles;
import java.util.ArrayList;
import java.util.Scanner;
/**
*
* @author cypronmaya
*/
class Point {
@phaniram
phaniram / find_str.java
Created January 3, 2012 10:32
Interview Street Challenges - Find Strings
package com.interviewstreet.puzzles;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;
public class find_str {
private static final String INVALID = "INVALID";
private TreeSet<String> mainset = new TreeSet<String>();
@phaniram
phaniram / k_diff.java
Created January 3, 2012 10:33
Interview Street Challenges - K Difference(Optimized)
package com.interviewstreet.puzzles;
import java.util.Arrays;
import java.util.Scanner;
/**
*
* @author cypronmaya
* K Difference - Interviewstreet Challenges (Optimal Solution)
*/
public class k_diff {
@phaniram
phaniram / Permutations.java
Created January 5, 2012 02:24
Unique Permutations of an int[]
public class Permutations {
public static boolean permuteLexically(int[] data) {
int k = data.length - 2;
while (data[k] >= data[k + 1]) {
k--;
if (k < 0) {
return false;
}
}
@phaniram
phaniram / Vertical_sticks.java
Created January 5, 2012 15:35
Interview Street Challenges - Vertical Sticks
import java.util.*;
public class Vertical_sticks {
public boolean permute(int[] data) {
int k = data.length - 2;
while (data[k] >= data[k + 1]) {
k--;
if (k < 0) {