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.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.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 {
// 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++) {