原文链接: https://leetcode-cn.com/problems/word-break 英文原文Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary …
标签详情
字典树 分类
原文链接: https://leetcode-cn.com/problems/word-break-ii 英文原文Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in any order. Note …
原文链接: https://leetcode-cn.com/problems/implement-trie-prefix-tree 英文原文A trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this dat…
原文链接: https://leetcode-cn.com/problems/design-add-and-search-words-data-structure 英文原文Design a data structure that supports adding new words and finding if a string matches any previously added string. Implement the WordDictionary class: WordDictiona…
原文链接: https://leetcode-cn.com/problems/word-search-ii 英文原文Given an m x n board of characters and a list of strings words, return all words on the board. Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells a…
原文链接: https://leetcode-cn.com/problems/palindrome-pairs 英文原文Given a list of unique words, return all the pairs of the distinct indices (i, j) in the given list, so that the concatenation of the two words words[i] + words[j] is a palindrome. Example 1…
原文链接: https://leetcode-cn.com/problems/lexicographical-numbers 英文原文Given an integer n, return all the numbers in the range [1, n] sorted in lexicographical order. You must write an algorithm that runs in O(n) time and uses O(1) extra space. Example 1…
原文链接: https://leetcode-cn.com/problems/maximum-xor-of-two-numbers-in-an-array 英文原文Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n. Example 1: Input: nums = [3,10,5,25,2,8] Output: 28 Explanation: T…
原文链接: https://leetcode-cn.com/problems/k-th-smallest-in-lexicographical-order 英文原文Given two integers n and k, return the kth lexicographically smallest integer in the range [1, n]. Example 1: Input: n = 13, k = 2 Output: 10 Explanation: The lexicogra…
原文链接: https://leetcode-cn.com/problems/concatenated-words 英文原文Given an array of strings words (without duplicates), return all the concatenated words in the given list of words. A concatenated word is defined as a string that is comprised entirely of…
原文链接: https://leetcode-cn.com/problems/replace-words 英文原文In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word successor. For example, when the root "an" is followed by …
原文链接: https://leetcode-cn.com/problems/implement-magic-dictionary 英文原文Design a data structure that is initialized with a list of different words. Provided a string, you should determine if you can change exactly one character in this string to match …
原文链接: https://leetcode-cn.com/problems/map-sum-pairs 英文原文Design a map that allows you to do the following: Maps a string key to a given value. Returns the sum of the values that have a key with a prefix equal to a given string. Implement the MapSum c…
原文链接: https://leetcode-cn.com/problems/top-k-frequent-words 英文原文Given an array of strings words and an integer k, return the k most frequent strings. Return the answer sorted by the frequency from highest to lowest. Sort the words with the same frequ…
原文链接: https://leetcode-cn.com/problems/longest-word-in-dictionary 英文原文Given an array of strings words representing an English Dictionary, return the longest word in words that can be built one character at a time by other words in words. If there is …
原文链接: https://leetcode-cn.com/problems/prefix-and-suffix-search 英文原文Design a special dictionary with some words that searchs the words in it by a prefix and a suffix. Implement the WordFilter class: WordFilter(string[] words) Initializes the object w…
原文链接: https://leetcode-cn.com/problems/short-encoding-of-words 英文原文A valid encoding of an array of words is any reference string s and array of indices indices such that: words.length == indices.length The reference string s ends with the '#' charact…
原文链接: https://leetcode-cn.com/problems/stream-of-characters 英文原文Design an algorithm that accepts a stream of characters and checks if a suffix of these characters is a string of a given array of strings words. For example, if words = ["abc", "xyz"] a…
原文链接: https://leetcode-cn.com/problems/distinct-echo-substrings 英文原文Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e. it can be written as a + a where a is some string…
原文链接: https://leetcode-cn.com/problems/number-of-valid-words-for-each-puzzle 英文原文With respect to a given puzzle string, a word is valid if both the following conditions are satisfied: word contains the first letter of puzzle. For each letter in word,…
原文链接: https://leetcode-cn.com/problems/remove-sub-folders-from-the-filesystem 英文原文Given a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order. If a folder[i] is located wi…
原文链接: https://leetcode-cn.com/problems/search-suggestions-system 英文原文Given an array of strings products and a string searchWord. We want to design a system that suggests at most three product names from products after each character of searchWord is …
原文链接: https://leetcode-cn.com/problems/delete-duplicate-folders-in-system 英文原文Due to a bug, there are many duplicate folders in a file system. You are given a 2D array paths, where paths[i] is an array representing an absolute path to the ith folder …
原文链接: https://leetcode-cn.com/problems/words-frequency-lcci 英文原文Design a method to find the frequency of occurrences of any given word in a book. What if we were running this algorithm multiple times? You should implement following methods: WordsFreq…
原文链接: https://leetcode-cn.com/problems/re-space-lcci 英文原文Oh, no! You have accidentally removed all spaces, punctuation, and capitalization in a lengthy document. A sentence like "I reset the computer. It still didn't boot!" became "iresetthecomputeri…
原文链接: https://leetcode-cn.com/problems/longest-word-lcci 英文原文Given a list of words, write a program to find the longest word made of other words in the list. If there are more than one answer, return the one that has smallest lexicographic order. If …
原文链接: https://leetcode-cn.com/problems/multi-search-lcci 英文原文Given a string band an array of smaller strings T, design a method to search b for each small string in T. Output positions of all strings in smalls that appear in big, where positions[i] i…
原文链接: https://leetcode-cn.com/problems/word-rectangle-lcci 英文原文Given a list of millions of words, design an algorithm to create the largest possible rectangle of letters such that every row forms a word (reading left to right) and every column forms …
原文链接: https://leetcode-cn.com/problems/UhWRSj 中文题目在英语中,有一个叫做 词根(root) 的概念,它可以跟着其他一些词组成另一个较长的单词——我们称这个词为 继承词(successor)。例如,词根an,跟随着单词 other(其他),可以形成新的单词 another(另一个)。 现在,给定一个由许多词根组成的词典和一个句子,需要将句子中的所有继承词用词根替换掉。如果继承词有许多可以形成它的词根,则用最短的词根替换它。 需…
原文链接: https://leetcode-cn.com/problems/US1pGT 中文题目设计一个使用单词列表进行初始化的数据结构,单词列表中的单词 互不相同 。 如果给出一个单词,请判定能否只将这个单词中一个字母换成另一个字母,使得所形成的新单词存在于已构建的神奇字典中。 实现 MagicDictionary 类: MagicDictionary() 初始化对象 void buildDict(String[] dictionary) 使用字符串数组 dictionary 设定该数据结…
1 / 2