原文链接: https://leetcode-cn.com/problems/flip-columns-for-maximum-number-of-equal-rows 英文原文You are given an m x n binary matrix matrix. You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the…
标签详情
哈希表 分类
原文链接: https://leetcode-cn.com/problems/largest-values-from-labels 英文原文There is a set of n items. You are given two integer arrays values and labels where the value and the label of the ith element are values[i] and labels[i] respectively. You are als…
原文链接: https://leetcode-cn.com/problems/relative-sort-array 英文原文Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1. Sort the elements of arr1 such that the relative ordering of items in arr1 ar…
原文链接: https://leetcode-cn.com/problems/lowest-common-ancestor-of-deepest-leaves 英文原文Given the root of a binary tree, return the lowest common ancestor of its deepest leaves. Recall that: The node of a binary tree is a leaf if and only if it has no ch…
原文链接: https://leetcode-cn.com/problems/longest-well-performing-interval 英文原文We are given hours, a list of the number of hours worked per day for a given employee. A day is considered to be a tiring day if and only if the number of hours worked is (st…
原文链接: https://leetcode-cn.com/problems/number-of-equivalent-domino-pairs 英文原文Given a list of dominoes, dominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a == c and b == d), or (a == d and b == c) - that is, one domino …
原文链接: https://leetcode-cn.com/problems/rank-transform-of-an-array 英文原文Given an array of integers arr, replace each element with its rank. The rank represents how large the element is. The rank has the following rules: Rank is an integer starting from…
原文链接: https://leetcode-cn.com/problems/snapshot-array 英文原文Implement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with the given length. Initially, each element equals 0. voi…
原文链接: https://leetcode-cn.com/problems/maximum-number-of-words-you-can-type 英文原文There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly. Given a string text of words separated by a single sp…
原文链接: https://leetcode-cn.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list 英文原文Given the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. After doing so, return…
原文链接: https://leetcode-cn.com/problems/dinner-plate-stacks 英文原文You have an infinite number of stacks arranged in a row and numbered (left to right) from 0, each of the stacks has the same maximum capacity. Implement the DinnerPlates class: DinnerPlat…
原文链接: https://leetcode-cn.com/problems/compare-strings-by-frequency-of-the-smallest-character 英文原文Let the function f(s) be the frequency of the lexicographically smallest character in a non-empty string s. For example, if s = "dcce" then f(s) = 2 bec…
原文链接: https://leetcode-cn.com/problems/can-make-palindrome-from-substring 英文原文You are given a string s and array queries where queries[i] = [lefti, righti, ki]. We may rearrange the substring s[lefti...righti] for each query and then choose up to ki …
原文链接: 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/maximum-number-of-balloons 英文原文Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible. You can use each character in text at most once. Return the…
原文链接: https://leetcode-cn.com/problems/smallest-string-with-swaps 英文原文You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string. You can swap the characters at …
原文链接: https://leetcode-cn.com/problems/unique-number-of-occurrences 英文原文Given an array of integers arr, return true if the number of occurrences of each value in the array is unique, or false otherwise. Example 1: Input: arr = [1,2,2,1,1,3] Output: t…
原文链接: https://leetcode-cn.com/problems/longest-arithmetic-subsequence-of-given-difference 英文原文Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the diff…
原文链接: https://leetcode-cn.com/problems/maximum-equal-frequency 英文原文Given an array nums of positive integers, return the longest possible length of an array prefix of nums, such that it is possible to remove exactly one element from this prefix so tha…
原文链接: https://leetcode-cn.com/problems/tuple-with-same-product 英文原文Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d where a, b, c, and d are elements of nums, and a != b != c != d. Ex…
原文链接: https://leetcode-cn.com/problems/count-number-of-nice-subarrays 英文原文Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it. Return the number of nice sub-arrays. Example 1: Input:…
原文链接: https://leetcode-cn.com/problems/find-winner-on-a-tic-tac-toe-game 英文原文Tic-tac-toe is played by two players A and B on a 3 x 3 grid. The rules of Tic-Tac-Toe are: Players take turns placing characters into empty squares ' '. The first player A …
原文链接: https://leetcode-cn.com/problems/group-the-people-given-the-group-size-they-belong-to 英文原文There are n people that are split into some unknown number of groups. Each person is labeled with a unique ID from 0 to n - 1. You are given an integer ar…
原文链接: https://leetcode-cn.com/problems/divide-array-in-sets-of-k-consecutive-numbers 英文原文Given an array of integers nums and a positive integer k, find whether it is possible to divide this array into sets of k consecutive numbers. Return true if it …
原文链接: https://leetcode-cn.com/problems/maximum-number-of-occurrences-of-a-substring 英文原文Given a string s, return the maximum number of ocurrences of any substring under the following rules: The number of unique characters in the substring must be les…
原文链接: https://leetcode-cn.com/problems/get-watched-videos-by-your-friends 英文原文There are n people, each person has a unique id between 0 and n-1. Given the arrays watchedVideos and friends, where watchedVideos[i] and friends[i] contain the list of wat…
原文链接: https://leetcode-cn.com/problems/jump-game-iv 英文原文Given an array of integers arr, you are initially positioned at the first index of the array. In one step you can jump from index i to index: i + 1 where: i + 1 < arr.length. i - 1 where: i - 1 …
原文链接: https://leetcode-cn.com/problems/apply-discount-every-n-orders 英文原文There is a supermarket that is frequented by many customers. The products sold at the supermarket are represented as two parallel integer arrays products and prices, where the i…
原文链接: https://leetcode-cn.com/problems/number-of-substrings-containing-all-three-characters 英文原文Given a string s consisting only of characters a, b and c. Return the number of substrings containing at least one occurrence of all these characters a, b…
原文链接: https://leetcode-cn.com/problems/reduce-array-size-to-the-half 英文原文You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. Return the minimum size of the set so that at…