原文链接: 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/parse-lisp-expression 英文原文You are given a string expression representing a Lisp-like expression to return the integer value of. The syntax for these expressions is given as follows. An expression is either an in…
原文链接: https://leetcode-cn.com/problems/number-of-atoms 英文原文Given a string formula representing a chemical formula, return the count of each atom. The atomic element always starts with an uppercase character, then zero or more lowercase letters, repre…
原文链接: https://leetcode-cn.com/problems/delete-and-earn 英文原文You are given an integer array nums. You want to maximize the number of points you get by performing the following operation any number of times: Pick any nums[i] and delete it to earn nums[i…
原文链接: https://leetcode-cn.com/problems/shortest-completing-word 英文原文Given a string licensePlate and an array of strings words, find the shortest completing word in words. A completing word is a word that contains all the letters in licensePlate. Igno…
原文链接: https://leetcode-cn.com/problems/partition-labels 英文原文You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. Return a list of integers representing the size of t…
原文链接: https://leetcode-cn.com/problems/reorganize-string 英文原文Given a string s, rearrange the characters of s so that any two adjacent characters are not the same. Return any possible rearrangement of s or return "" if not possible. Example 1: Input: …
原文链接: https://leetcode-cn.com/problems/basic-calculator-iv 英文原文Given an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {"e": 1} (given in terms of evalvars = ["e"] and evalints = [1]), return a list of tokens representi…
原文链接: https://leetcode-cn.com/problems/jewels-and-stones 英文原文You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to …
原文链接: https://leetcode-cn.com/problems/custom-sort-string 英文原文You are given two strings order and s. All the words of order are unique and were sorted in some custom order previously. Permute the characters of s so that they match the order that orde…
原文链接: https://leetcode-cn.com/problems/design-hashset 英文原文Design a HashSet without using any built-in hash table libraries. Implement MyHashSet class: void add(key) Inserts the value key into the HashSet. bool contains(key) Returns whether the value …
原文链接: https://leetcode-cn.com/problems/design-hashmap 英文原文Design a HashMap without using any built-in hash table libraries. Implement the MyHashMap class: MyHashMap() initializes the object with an empty map. void put(int key, int value) inserts a (k…
原文链接: https://leetcode-cn.com/problems/unique-morse-code-words 英文原文International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: 'a' maps to ".-", 'b' maps to "-...", 'c' maps to "-.-.", …
原文链接: https://leetcode-cn.com/problems/subdomain-visit-count 英文原文A website domain "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com" and at the lowest level, "discuss.leet…
原文链接: https://leetcode-cn.com/problems/bus-routes 英文原文You are given an array routes representing bus routes where routes[i] is a bus route that the ith bus repeats forever. For example, if routes[0] = [1, 5, 7], this means that the 0th bus travels in…
原文链接: https://leetcode-cn.com/problems/linked-list-components 英文原文You are given the head of a linked list containing unique integer values and an integer array nums that is a subset of the linked list values. Return the number of connected components…
原文链接: https://leetcode-cn.com/problems/most-common-word 英文原文Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and …
原文链接: 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/binary-trees-with-factors 英文原文Given an array of unique integers, arr, where each integer arr[i] is strictly greater than 1. We make a binary tree using these integers, and each number may be used for any number …
原文链接: https://leetcode-cn.com/problems/hand-of-straights 英文原文Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size groupSize, and consists of groupSize consecutive cards. Given an integer array …
原文链接: https://leetcode-cn.com/problems/buddy-strings 英文原文Given two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false. Swapping letters is defined as taking two indices i and j (0-…
原文链接: https://leetcode-cn.com/problems/random-pick-with-blacklist 英文原文You are given an integer n and an array of unique integers blacklist. Design an algorithm to pick a random integer in the range [0, n - 1] that is not in blacklist. Any integer tha…
原文链接: https://leetcode-cn.com/problems/smallest-subtree-with-all-the-deepest-nodes 英文原文Given the root of a binary tree, the depth of each node is the shortest distance to the root. Return the smallest subtree such that it contains all the deepest nod…
原文链接: https://leetcode-cn.com/problems/length-of-longest-fibonacci-subsequence 英文原文A sequence x1, x2, ..., xn is Fibonacci-like if: n >= 3 xi + xi+1 == xi+2 for all i + 2 <= n Given a strictly increasing array arr of positive integers forming a seque…
原文链接: https://leetcode-cn.com/problems/random-flip-matrix 英文原文There is an m x n binary grid matrix with all the values set 0 initially. Design an algorithm to randomly pick an index (i, j) where matrix[i][j] == 0 and flips it to 1. All the indices (i…
原文链接: https://leetcode-cn.com/problems/uncommon-words-from-two-sentences 英文原文A sentence is a string of single-space separated words where each word consists only of lowercase letters. A word is uncommon if it appears exactly once in one of the senten…
原文链接: https://leetcode-cn.com/problems/fair-candy-swap 英文原文Alice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of candies of the ith box of candy that Alic…
原文链接: https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal 英文原文Given two integer arrays, preorder and postorder where preorder is the preorder traversal of a binary tree of distinct values and postorder is the …
原文链接: https://leetcode-cn.com/problems/find-and-replace-pattern 英文原文Given a list of strings words and a string pattern, return a list of words[i] that match pattern. You may return the answer in any order. A word matches the pattern if there exists a…
原文链接: https://leetcode-cn.com/problems/groups-of-special-equivalent-strings 英文原文You are given an array of strings of the same length words. In one move, you can swap any two even indexed characters or any two odd indexed characters of a string words[…