原文链接: https://leetcode-cn.com/problems/maximum-frequency-stack 英文原文Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack. Implement the FreqStack class: FreqStack() constructs an empty frequ…
标签详情
哈希表 分类
原文链接: https://leetcode-cn.com/problems/fruit-into-baskets 英文原文You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where fruits[i] is the type of fruit the ith …
原文链接: https://leetcode-cn.com/problems/online-election 英文原文You are given two integer arrays persons and times. In an election, the ith vote was cast for persons[i] at time times[i]. For each query at a time t, find the person that was leading the ele…
原文链接: https://leetcode-cn.com/problems/x-of-a-kind-in-a-deck-of-cards 英文原文In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more gr…
原文链接: https://leetcode-cn.com/problems/word-subsets 英文原文You are given two string arrays words1 and words2. A string b is a subset of string a if every letter in b occurs in a including multiplicity. For example, "wrr" is a subset of "warrior" but is …
原文链接: https://leetcode-cn.com/problems/3sum-with-multiplicity 英文原文Given an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target. As the answer can be very large, retu…
原文链接: https://leetcode-cn.com/problems/binary-subarrays-with-sum 英文原文Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal. A subarray is a contiguous part of the array. Example 1: Input: nums = [1,0,…
原文链接: https://leetcode-cn.com/problems/minimum-area-rectangle 英文原文You are given an array of points in the X-Y plane points where points[i] = [xi, yi]. Return the minimum area of a rectangle formed from these points, with sides parallel to the X and Y…
原文链接: https://leetcode-cn.com/problems/verifying-an-alien-dictionary 英文原文In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letter…
原文链接: https://leetcode-cn.com/problems/array-of-doubled-pairs 英文原文Given an integer array of even length arr, return true if it is possible to reorder arr such that arr[2 * i + 1] = 2 * arr[2 * i] for every 0 <= i < len(arr) / 2, or false otherwise. E…
原文链接: https://leetcode-cn.com/problems/prison-cells-after-n-days 英文原文There are 8 prison cells in a row and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to the following rules: If a cell ha…
原文链接: https://leetcode-cn.com/problems/n-repeated-element-in-size-2n-array 英文原文You are given an integer array nums with the following properties: nums.length == 2 * n. nums contains n + 1 unique elements. Exactly one element of nums is repeated n tim…
原文链接: https://leetcode-cn.com/problems/vowel-spellchecker 英文原文Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word. For a given query word, the spell checker handles two categories of spelling mistakes:…
原文链接: https://leetcode-cn.com/problems/powerful-integers 英文原文Given three integers x, y, and bound, return a list of all the powerful integers that have a value less than or equal to bound. An integer is powerful if it can be represented as xi + yj fo…
原文链接: https://leetcode-cn.com/problems/subarray-sums-divisible-by-k 英文原文Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k. A subarray is a contiguous part of an array. Example 1: Inp…
原文链接: https://leetcode-cn.com/problems/time-based-key-value-store 英文原文Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp. Implement…
原文链接: https://leetcode-cn.com/problems/triples-with-bitwise-and-equal-to-zero 英文原文Given an integer array nums, return the number of AND triples. An AND triple is a triple of indices (i, j, k) such that: 0 <= i < nums.length 0 <= j < nums.length 0 <= …
原文链接: https://leetcode-cn.com/problems/vertical-order-traversal-of-a-binary-tree 英文原文Given the root of a binary tree, calculate the vertical order traversal of the binary tree. For each node at position (row, col), its left and right children will be…
原文链接: https://leetcode-cn.com/problems/subarrays-with-k-different-integers 英文原文Given an integer array nums and an integer k, return the number of good subarrays of nums. A good array is an array where the number of different integers in that array is…
原文链接: https://leetcode-cn.com/problems/find-the-town-judge 英文原文In a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: The town judge trusts nobody. Ever…
原文链接: https://leetcode-cn.com/problems/grid-illumination 英文原文There is a 2D grid of size n x n where each cell of this grid has a lamp that is initially turned off. You are given a 2D array of lamp positions lamps, where lamps[i] = [rowi, coli] indica…
原文链接: https://leetcode-cn.com/problems/find-common-characters 英文原文Given a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the answer in any order. Example 1: In…
原文链接: https://leetcode-cn.com/problems/pairs-of-songs-with-total-durations-divisible-by-60 英文原文You are given a list of songs where the ith song has a duration of time[i] seconds. Return the number of pairs of songs for which their total duration in s…
原文链接: https://leetcode-cn.com/problems/smallest-integer-divisible-by-k 英文原文Given a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digit 1. Return the length of…
原文链接: https://leetcode-cn.com/problems/longest-arithmetic-subsequence 英文原文Given an array nums of integers, return the length of the longest arithmetic subsequence in nums. Recall that a subsequence of an array nums is a list nums[i1], nums[i2], ..., …
原文链接: https://leetcode-cn.com/problems/escape-a-large-maze 英文原文There is a 1 million by 1 million grid on an XY-plane, and the coordinates of each grid square are (x, y). We start at the source = [sx, sy] square and want to reach the target = [tx, ty]…
原文链接: https://leetcode-cn.com/problems/find-words-that-can-be-formed-by-characters 英文原文You are given an array of strings words and a string chars. A string is good if it can be formed by characters from chars (each character can only be used once). R…
原文链接: https://leetcode-cn.com/problems/longest-string-chain 英文原文You are given an array of words where each word consists of lowercase English letters. wordA is a predecessor of wordB if and only if we can insert exactly one letter anywhere in wordA w…
原文链接: https://leetcode-cn.com/problems/distant-barcodes 英文原文In a warehouse, there is a row of barcodes, where the ith barcode is barcodes[i]. Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guar…
原文链接: https://leetcode-cn.com/problems/number-of-submatrices-that-sum-to-target 英文原文Given a matrix and a target, return the number of non-empty submatrices that sum to target. A submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <=…