原文链接: https://leetcode-cn.com/problems/combination-sum-iv 英文原文Given an array of distinct integers nums and a target integer target, return the number of possible combinations that add up to target. The answer is guaranteed to fit in a 32-bit integer.…
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/kth-smallest-element-in-a-sorted-matrix 英文原文Given an n x n matrix where each of the rows and columns is sorted in ascending order, return the kth smallest element in the matrix. Note that it is the kth smallest …
原文链接: https://leetcode-cn.com/problems/insert-delete-getrandom-o1 英文原文Implement the RandomizedSet class: RandomizedSet() Initializes the RandomizedSet object. bool insert(int val) Inserts an item val into the set if not present. Returns true if the i…
原文链接: https://leetcode-cn.com/problems/linked-list-random-node 英文原文Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen. Implement the Solution class: Solution(ListNod…
原文链接: https://leetcode-cn.com/problems/shuffle-an-array 英文原文Given an integer array nums, design an algorithm to randomly shuffle the array. All permutations of the array should be equally likely as a result of the shuffling. Implement the Solution cl…
原文链接: https://leetcode-cn.com/problems/mini-parser 英文原文Given a string s represents the serialization of a nested list, implement a parser to deserialize it and return the deserialized NestedInteger. Each element is either an integer or a list whose e…
原文链接: 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/longest-absolute-file-path 英文原文Suppose we have a file system that stores both files and directories. An example of one system is represented in the following picture: Here, we have dir as the only directory in t…
原文链接: https://leetcode-cn.com/problems/utf-8-validation 英文原文Given an integer array data representing the data, return whether it is a valid UTF-8 encoding. A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules: For a 1-b…
原文链接: https://leetcode-cn.com/problems/decode-string 英文原文Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k i…
原文链接: https://leetcode-cn.com/problems/longest-substring-with-at-least-k-repeating-characters 英文原文Given a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is greate…
原文链接: https://leetcode-cn.com/problems/rotate-function 英文原文You are given an integer array nums of length n. Assume arrk to be an array obtained by rotating nums by k positions clock-wise. We define the rotation function F on nums as follow: F(k) = 0 …
原文链接: https://leetcode-cn.com/problems/integer-replacement 英文原文Given a positive integer n, you can apply one of the following operations: If n is even, replace n with n / 2. If n is odd, replace n with either n + 1 or n - 1. Return the minimum number…
原文链接: https://leetcode-cn.com/problems/random-pick-index 英文原文Given an integer array nums with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array. Implement the …
原文链接: https://leetcode-cn.com/problems/nth-digit 英文原文Given an integer n, return the nth digit of the infinite integer sequence [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]. Example 1: Input: n = 3 Output: 3 Example 2: Input: n = 11 Output: 0 Explanation:…
原文链接: https://leetcode-cn.com/problems/evaluate-division 英文原文You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi = values[i]. Each Ai or Bi…
原文链接: https://leetcode-cn.com/problems/remove-k-digits 英文原文Given string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num. Example 1: Input: num = "1432219", k = 3 Out…
原文链接: https://leetcode-cn.com/problems/queue-reconstruction-by-height 英文原文You are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order). Each people[i] = [hi, ki] represents the ith person of …
原文链接: https://leetcode-cn.com/problems/elimination-game 英文原文You have a list arr of all integers in the range [1, n] sorted in a strictly increasing order. Apply the following algorithm on arr: Starting from left to right, remove the first number and …
原文链接: https://leetcode-cn.com/problems/partition-equal-subset-sum 英文原文Given a non-empty array nums containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. Exampl…
原文链接: https://leetcode-cn.com/problems/pacific-atlantic-water-flow 英文原文There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touc…
原文链接: https://leetcode-cn.com/problems/battleships-in-a-board 英文原文Given an m x n matrix board where each cell is a battleship 'X' or empty '.', return the number of the battleships on board. Battleships can only be placed horizontally or vertically o…
原文链接: 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/reconstruct-original-digits-from-english 英文原文Given a string s containing an out-of-order English representation of digits 0-9, return the digits in ascending order. Example 1: Input: s = "owoztneoer" Output: "01…
原文链接: https://leetcode-cn.com/problems/minimum-genetic-mutation 英文原文A gene string can be represented by an 8-character long string, with choices from 'A', 'C', 'G', and 'T'. Suppose we need to investigate a mutation from a gene string start to a gene…
原文链接: https://leetcode-cn.com/problems/non-overlapping-intervals 英文原文Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlappin…
原文链接: https://leetcode-cn.com/problems/find-right-interval 英文原文You are given an array of intervals, where intervals[i] = [starti, endi] and each starti is unique. The right interval for an interval i is an interval j such that startj >= endi and star…
原文链接: https://leetcode-cn.com/problems/path-sum-iii 英文原文Given the root of a binary tree and an integer targetSum, return the number of paths where the sum of the values along the path equals targetSum. The path does not need to start or end at the ro…
原文链接: https://leetcode-cn.com/problems/find-all-anagrams-in-a-string 英文原文Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order. An Anagram is a word or phrase formed by rearra…
原文链接: https://leetcode-cn.com/problems/find-all-duplicates-in-an-array 英文原文Given an integer array nums of length n where all the integers of nums are in the range [1, n] and each integer appears once or twice, return an array of all the integers that…