Skip to content

Instantly share code, notes, and snippets.

View Abhishek-Chaudhary-InfoCepts's full-sized avatar

abhishek Abhishek-Chaudhary-InfoCepts

View GitHub Profile
package com.abhishek.dojo;
import java.util.Arrays;
// http://buttercola.blogspot.com/2015/09/leetcode-walls-and-gates.html
public class WallsAndGates {
public static void main(String[] args) {
int[][] grid = new int[][] {
{2147483647, -1, 0, 2147483647},
package com.abhishek.dojo;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
public class MinimumMutationGene {
public static void main(String[] args) {
minMutation("AACCGGTT", "AAACGGTA", new String[] {"AACCGGTA", "AACCGCTA", "AAACGGTA"});
package com.abhishek.dojo;
public class BuySellStocks {
public static void main(String[] args) {
BuySellStocks bss = new BuySellStocks();
// case 1- stock price always increasing
// you need to buy first and sell later
// Lowest buy value- 10
package com.abhishek.dojo;
import java.util.HashSet;
/*Write an algorithm to determine if a number is "happy".
A happy number is a number defined by the following process:
Starting with any positive integer, replace the number by the sum of
the squares of its digits, and repeat the process until the number
equals 1 (where it will stay), or it loops endlessly in a cycle
package com.abhishek.dojo;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Optional;
public class LongestIncreasingSubsequence {
public static void main(String[] args) {
package com.abhishek.dojo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.PriorityQueue;
public class TopKRepeatingElements {
class Pair {
int num;
package com.abhishek.dojo.arrays;
import java.util.ArrayList;
import java.util.Arrays;
public class MergeSortedArrays {
public static int[] mergeArrays(int[] firstArr, int[] secondArr) {
ArrayList test = new ArrayList(Arrays.asList("a", "b", "c"));
// combine the sorted arrays into one large sorted array
package com.abhishek.dojo.arrays;
//reference- https://www.youtube.com/watch?v=CGMNePwovA0
public class NumberofIslandsChar {
public static void main(String[] args) {
NumberofIslandsChar n = new NumberofIslandsChar();
// expected = 3
char[][] grid = { { '1', '1', '0', '0', '0' },
package com.abhishek.dojo;
import java.util.HashMap;
import java.util.Map;
public class WordCloud {
private Map<String, Integer> wordsToCounts = new HashMap<String, Integer>();
public WordCloudData(String inputString) {
populateWordsToCounts(inputString);
package com.abhishek.dojo.lru;
import java.util.Iterator;
import java.util.LinkedHashMap;
public class LRUCache {
private int capacity;
// use linkedhashmap to maintain the sequence