原文链接: https://leetcode-cn.com/problems/4sum-ii 英文原文Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that: 0 <= i, j, k, l < n nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0 Exampl…
标签详情
哈希表 分类
原文链接: https://leetcode-cn.com/problems/circular-array-loop 英文原文You are playing a game involving a circular array of non-zero integers nums. Each nums[i] denotes the number of indices forward/backward you must move if you are located at index i: If nu…
原文链接: https://leetcode-cn.com/problems/lfu-cache 英文原文Design and implement a data structure for a Least Frequently Used (LFU) cache. Implement the LFUCache class: LFUCache(int capacity) Initializes the object with the capacity of the data structure. i…
原文链接: https://leetcode-cn.com/problems/sliding-window-median 英文原文The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle values. For examples, i…
原文链接: https://leetcode-cn.com/problems/increasing-subsequences 英文原文Given an integer array nums, return all the different possible increasing subsequences of the given array with at least two elements. You may return the answer in any order. The given…
原文链接: https://leetcode-cn.com/problems/next-greater-element-i 英文原文The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two distinct 0-indexed integer arrays num…
原文链接: https://leetcode-cn.com/problems/keyboard-row 英文原文Given an array of strings words, return the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below. In the American keyboard: the first r…
原文链接: https://leetcode-cn.com/problems/most-frequent-subtree-sum 英文原文Given the root of a binary tree, return the most frequent subtree sum. If there is a tie, return all the values with the highest frequency in any order. The subtree sum of a node is…
原文链接: https://leetcode-cn.com/problems/longest-uncommon-subsequence-ii 英文原文Given an array of strings strs, return the length of the longest uncommon subsequence between them. If the longest uncommon subsequence does not exist, return -1. An uncommon …
原文链接: https://leetcode-cn.com/problems/continuous-subarray-sum 英文原文Given an integer array nums and an integer k, return true if nums has a continuous subarray of size at least two whose elements sum up to a multiple of k, or false otherwise. An integ…
原文链接: https://leetcode-cn.com/problems/contiguous-array 英文原文Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1. Example 1: Input: nums = [0,1] Output: 2 Explanation: [0, 1] is the longest con…
原文链接: https://leetcode-cn.com/problems/encode-and-decode-tinyurl 英文原文Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/desig…
原文链接: https://leetcode-cn.com/problems/brick-wall 英文原文There is a rectangular brick wall in front of you with n rows of bricks. The ith row has some number of bricks each of the same height (i.e., one unit) but they can be of different widths. The tot…
原文链接: https://leetcode-cn.com/problems/subarray-sum-equals-k 英文原文Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum equals to k. Example 1: Input: nums = [1,1,1], k = 2 Output: 2 Example 2: Inp…
原文链接: https://leetcode-cn.com/problems/permutation-in-string 英文原文Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1's permutations is the substring of s2. Example …
原文链接: https://leetcode-cn.com/problems/distribute-candies 英文原文Alice has n candies, where the ith candy is of type candyType[i]. Alice noticed that she started to gain weight, so she visited a doctor. The doctor advised Alice to only eat n / 2 of the …
原文链接: https://leetcode-cn.com/problems/longest-harmonious-subsequence 英文原文We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1. Given an integer array nums, return the length of it…
原文链接: https://leetcode-cn.com/problems/minimum-index-sum-of-two-lists 英文原文Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need to help them find out their co…
原文链接: https://leetcode-cn.com/problems/find-duplicate-file-in-system 英文原文Given a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files in the file system in terms…
原文链接: https://leetcode-cn.com/problems/task-scheduler 英文原文Given a characters array tasks, representing the tasks a CPU needs to do, where each letter represents a different task. Tasks could be done in any order. Each task is done in one unit of time…
原文链接: https://leetcode-cn.com/problems/smallest-range-covering-elements-from-k-lists 英文原文You have k lists of sorted integers in non-decreasing order. Find the smallest range that includes at least one number from each of the k lists. We define the ra…
原文链接: https://leetcode-cn.com/problems/set-mismatch 英文原文You have a set of integers s, which originally contains all the numbers from 1 to n. Unfortunately, due to some error, one of the numbers in s got duplicated to another number in the set, which …
原文链接: 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/two-sum-iv-input-is-a-bst 英文原文Given the root of a Binary Search Tree and a target number k, return true if there exist two elements in the BST such that their sum is equal to the given target. Example 1: Input: …
原文链接: https://leetcode-cn.com/problems/split-array-into-consecutive-subsequences 英文原文You are given an integer array nums that is sorted in non-decreasing order. Determine if it is possible to split nums into one or more subsequences such that both of…
原文链接: 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/employee-importance 英文原文You have a data structure of employee information, including the employee's unique ID, importance value, and direct subordinates' IDs. You are given an array of employees employees where:…
原文链接: 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/degree-of-an-array 英文原文Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. Your task is to find the smallest possible l…