Skip to content

Instantly share code, notes, and snippets.

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

abhishek Abhishek-Chaudhary-InfoCepts

View GitHub Profile
// 1. word break 1
public boolean dfs(String s, List<String> wordDict) {
return dfs(s, new HashSet<>(wordDict), 0);
}
public boolean dfs(String s, Set<String> wordDict, int start) {
if (start == s.length()) {
return true;
}
for (int end = start + 1; end <= s.length(); end++) {
package com.dojo.java8.tutorials.hashmap;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
public class HashMapSortingByValues {
package com.dojo.java8.tutorials.hashmap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
public class HashMapSortingByKeys {
package com.ge.current.points;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.TreeMap;
import java.util.TreeSet;
public class SortData {
public static void main(String[] args) {
/**
* Constructs a new, empty tree set, sorted according to the specified
* comparator. All elements inserted into the set must be <i>mutually
* comparable</i> by the specified comparator: {@code comparator.compare(e1,
* e2)} must not throw a {@code ClassCastException} for any elements
* {@code e1} and {@code e2} in the set. If the user attempts to add
* an element to the set that violates this constraint, the
* {@code add} call will throw a {@code ClassCastException}.
*
* @param comparator the comparator that will be used to order this set.
class Solution {
public int numIslands(char[][] grid) {
int count =0;
if (grid.length == 0){
return 0;
}
boolean [][] visited = new boolean[grid.length][grid[0].length];
for (int i =0; i < grid.length; i++){
for (int j = 0 ; j < grid[0].length; j++){
if (grid[i][j]=='1' && !visited[i][j]){
package com.abhishek.dojo.guess.output;
public class ChangeObjectReferenceInsideMethod {
public class A {
int attr;
public void setAttr(int a) {
this.attr = a;
}
}
package com.interview.dynamic;
public class WildCardMatching {
public boolean isMatch(String s, String p) {
char[] str = s.toCharArray();
char[] pattern = p.toCharArray();
//replace multiple * with one *
//e.g a**b***c --> a*b*c
int writeIndex = 0;
boolean isFirst = true;
package com.abhishek.dojo;
import java.util.ArrayList;
import java.util.List;
public class MaximumSumOfTriangularSeries {
public static void main(String[] args) {
List<List<Integer>> triangle = new ArrayList<List<Integer>>();
ArrayList<Integer> test = new ArrayList<Integer>();
test.add(2);
public class UniquePath {
public int uniquePaths(int m, int n) {
// add more comments
if (m == 0 || n == 0) {
return 0;
}
int[][] dp = new int[m][n];