This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.util.Pair; | |
import java.util.HashSet; | |
import java.util.Set; | |
interface Robot { | |
boolean move(); | |
void turnLeft(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class TrieNode { | |
//Hash map of character to trie node | |
HashMap<Character, TrieNode> children = new HashMap<Character, TrieNode>(); | |
//A string to store the possible found words for each node | |
String word = null; | |
public TrieNode() {} | |
} | |
class Solution { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public String alienOrder(String[] words) { | |
//For catching Errors | |
if(words.length==0) return ""; | |
//The dependencyMap and countMap data structures | |
Map<Character, Set<Character>> dependencyMap = new HashMap<>(); | |
Map<Character, Integer> countMap = new HashMap<>(); | |
//a boolean that determines whether we can build a graph or not | |
boolean success = buildGraph(words, dependencyMap, countMap); | |
if(!success) return ""; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
Map<String, List<String>> adjList = new HashMap<String, List<String>>(); | |
List<String> currPath = new ArrayList<String>(); | |
List<List<String>> shortestPaths = new ArrayList<List<String>>(); | |
public List<List<String>> findLadders(String beginWord, String endWord, List<String> wordList) { | |
// copying the words into the set for efficient deletion in BFS | |
Set<String> copiedWordList = new HashSet<>(wordList); | |
// build the graph using BFS | |
bfs(beginWord, endWord, copiedWordList); |
OlderNewer