随笔分类 -  trie

336. Palindrome Pairs
摘要:Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome. Example 1: Input: ["ab... 阅读全文

posted @ 2018-11-09 07:20 猪猪🐷

527. Word Abbreviation
摘要:Given an array of n distinct non-empty strings, you need to generate minimal possible abbreviations for every word following rules below. 1. Begin with the first character and then the number of char... 阅读全文

posted @ 2018-11-08 02:32 猪猪🐷

642. Design Search Autocomplete System
摘要:Design a search autocomplete system for a search engine. Users may input a sentence (at least one word and end with a special character '#'). For each character they type except '#', you need to retu... 阅读全文

posted @ 2018-11-06 10:12 猪猪🐷

648. Replace Words
摘要:In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successor. For example, the root an, followed by other, which c... 阅读全文

posted @ 2018-11-06 10:11 猪猪🐷

745. Prefix and Suffix Search
摘要:Given many words, words[i] has weight i. Design a class WordFilter that supports one function, WordFilter.f(String prefix, String suffix). It will return the word with given prefix and suffix with ma... 阅读全文

posted @ 2018-11-06 10:10 猪猪🐷

676. Implement Magic Dictionary
摘要:Implement a magic directory with buildDict, and search methods. For the method buildDict, you'll be given a list of non-repetitive words to build a dictionary. For the method search, you'll be given ... 阅读全文

posted @ 2018-11-06 10:09 猪猪🐷

720. Longest Word in Dictionary
摘要:Given a list of strings words representing an English Dictionary, find the longest word in words that can be built one character at a time by other words in words. If there is more than one possible ... 阅读全文

posted @ 2018-11-06 10:08 猪猪🐷

425. Word Squares
摘要:Given a set of words (without duplicates), find all word squares you can build from them. A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤... 阅读全文

posted @ 2018-11-06 09:29 猪猪🐷

211 Add and Search Word - Data structure design
摘要:Design a data structure that supports the following two operations: search(word) can search a literal word or a regular expression string containing o 阅读全文

posted @ 2018-08-09 18:39 猪猪🐷

212. Word Search II
摘要:再尝试用 isWord boolean 的方式创建 trienode , 做下这道题。 Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be c 阅读全文

posted @ 2018-08-09 17:28 猪猪🐷

208 implement trie
摘要:208 impement trie Implement a trie with insert, search, and startsWith methods. Example: Trie trie = new Trie(); trie.insert("apple"); trie.search("apple"); // returns true trie.search("app"); ... 阅读全文

posted @ 2018-08-09 17:27 猪猪🐷

导航