Skip to content

Instantly share code, notes, and snippets.

View gauravbhasin87's full-sized avatar
🏠
Working from home

gauravbhasin87

🏠
Working from home
View GitHub Profile
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static int distributeCandy(int [] score){
int [] fromLeft = new int[score.length];
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static int distributeCandy(int [] score){
int [] fromLeft = new int[score.length];
public class MergeSortedArray {
public static void main(String[] args) {
// TODO Auto-generated method stub
int ar1[] = {1,4,5,6,10,11};
int ar2[] = {2,3,4,5,6,7};
int [] result = merge(ar1,ar2);
import java.util.HashSet;
public class RepeatedString {
public static void findRepeated(String str){
HashSet<String> set = new HashSet<>();
//System.out.println(str);
String [] array = str.split(" |\\t|\\.|-|;");
int size = array.length;
for(int i=0;i<size;i++){
public class WeddingPlanner {
static boolean matchfound = false;
static double extrapolate(int amount, double[] unitCosts, int []amounts){
int indexes[] = findIndex(amount,amounts);
System.out.println(indexes[0] +" "+ indexes[1] );
int offer1 = amounts[indexes[0]];
int offer2 = amounts[indexes[1]];
double unit1 = unitCosts[indexes[0]];
public class Ksubsequence {
public static int solve(int[] arr, int d)
{
Object o;
int Answer = 0;
int[] hash = new int[d];
int sum = 0;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class RegExp {
static void findDomain(String str){
String p = "http://(www|ww2|web)\\.(\\w+\\.)+(\\w+)/";
Pattern pattern = Pattern.compile(p);
@gauravbhasin87
gauravbhasin87 / LCA.java
Created March 20, 2016 22:47
Binary Search Tree : Lowest Common Ancestor
/* Node is defined as :
class Node
int data;
Node left;
Node right;
*/
@gauravbhasin87
gauravbhasin87 / SherlockandAnagrams.java
Created March 20, 2016 22:44
Sherlock and Anagrams
/*
Given a string SS, find the number of "unordered anagrammatic pairs" of substrings.
Input Format
First line contains TT, the number of testcases. Each testcase consists of string SS in one line.
Constraints
1≤T≤101≤T≤10
2≤length(S)≤1002≤length(S)≤100
String SS contains only the lowercase letters of the English alphabet.
/*
You are given two strings, AA and BB. Find if there is a substring that appears in both AA and BB.
Input Format
Several test cases will be given to you in a single file. The first line of the input will contain a single integer TT, the number of test cases.
Then there will be TT descriptions of the test cases. Each description contains two lines. The first line contains the string AA and the second line contains the string BB.
Output Format