Skip to content

Instantly share code, notes, and snippets.

View SumitJainUTD's full-sized avatar

Sumit Jain SumitJainUTD

  • SDET @ Roku
  • Dallas
View GitHub Profile
import java.util.*;
public class Concordance {
static class Word{
String text;
int count;
public Word(String text, int count ){
this.text = text;
this.count = count;
public class Palindrome2 {
public static boolean isPalindrome(String input){
if (input==null)
return false;
if(input.trim()==""){
return true;
}
int i = 0;
int j = input.length()-1;
// "Race car!"
import java.util.HashMap;
import java.util.Map;
public class VersionControlMapSystem {
private static Integer currentVersion = null;
private static VersionControlMapSystem versionControlMapSystem;
private Map<Integer, Map<String, String>> controlMap = new HashMap<>();
private VersionControlMapSystem(){
public class CalculateModOfPow {
public static void calculateModOfPow(int x, int y, int z){
int result = calculate(x, y, z);
System.out.println("("+x+" ^ "+y+") % "+z+" = "+result);
}
public static int calculate(int n, int y, int z){
if(y==0)
return 1;
import java.util.Arrays;
public class CountPairsWithEvenSum {
public static void countPairs(int [] input){
System.out.println("Given Input: " + Arrays.toString(input));
int evenCount=0;
int oddCount=0;
import java.util.ArrayList;
import java.util.Arrays;
public class PrintTwoEqualArray {
public boolean partition(int [] input){
System.out.println("Given array: " + Arrays.toString(input));
int sum = 0;
for (int i = 0; i <input.length ; i++) {
sum +=input[i];
public class QuickSort {
private int[] arrA;
public QuickSort(int[] arrA) {
this.arrA = arrA;
}
public void quickS(int low, int high) {
int mid = (low + high) / 2;
int left = low;
public class WellFormedParentheses {
public Boolean isWellFormed(String strParentheses) {
if (strParentheses == null) {
return false;
}
// Idea is to have two counters, one for open parentheses '{' and one
// for close '}'
// Read one character at a time and increment one of the counters
// If any given point of time count of close parentheses is greater than
//Here objective is find an element in two dimensional array
//all rows and columns of an array are sorted in ascending order respectively
public class FindElementInSorted2DArray {
public Boolean findElement(int[][] arrA, int number) {
// start from the left top corner, say ele;
// if ele>number -> move left
// if ele<number -> move right
// if you cant move further to find the number , return false
int row = 0;
package interviewQuestion;
//Use recursive approach
//Compare first and last characters if they are not same- return false
//If they are same make, remove the first and last characters and make a recursive call.
public class Palindrome {
public Boolean isPalindrome(String strX) {
if (strX.length() < 2)
return true;