Set of Patterns to solve many algorithmic questions of similar type on LeetCode leetcodetriebacktrackingbinary-search-treearraysdynamic-programmingbreadth-first-searchgreedy-algorithmsdepth-first-searchunion-fin
❓ FIND ALL WORDS WITH GIVEN PREFIX 🐣 Word Search, Word Break Problem, etc. 🎭 PsuendoCode 📘 Trie Pattern 📘 ⏰: O(n) 🪐: O(n) TrieNode root = new TrieNode(); for (String word : words) { TrieNode node = root; for (char letter : word.toCharArray()) { if (node...
To transform the two dimension problem into the classic UF, perform a linear mapping: intid = n * x + y; Initially assume every cell are in non-island set{-1}. When point A is added, we create a new root, i.e., a new island. Then, check if any of its 4 neighbors belong to...
LeetCode题目:685. Redundant Connection II In this problem, a rooted tree is adirected 有向图graph such that,there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, except for the root node which has no parents...