原文链接: https://leetcode-cn.com/problems/h-index-ii 英文原文Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper and citations is sorted in an ascending order, return compute the resea…
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/perfect-squares 英文原文Given an integer n, return the least number of perfect square numbers that sum to n. A perfect square is an integer that is the square of an integer; in other words, it is the product of some…
原文链接: https://leetcode-cn.com/problems/peeking-iterator 英文原文Design an iterator that supports the peek operation on an existing iterator in addition to the hasNext and the next operations. Implement the PeekingIterator class: PeekingIterator(Iterator<…
原文链接: https://leetcode-cn.com/problems/find-the-duplicate-number 英文原文Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one repeated number in nums, return this repeated number…
原文链接: https://leetcode-cn.com/problems/game-of-life 英文原文According to Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970." The board is made up of …
原文链接: https://leetcode-cn.com/problems/bulls-and-cows 英文原文You are playing the Bulls and Cows game with your friend. You write down a secret number and ask your friend to guess what the number is. When your friend makes a guess, you provide a hint wit…
原文链接: https://leetcode-cn.com/problems/longest-increasing-subsequence 英文原文Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence is a sequence that can be derived from an array by deleting some or…
原文链接: https://leetcode-cn.com/problems/range-sum-query-2d-immutable 英文原文Given a 2D matrix matrix, handle multiple queries of the following type: Calculate the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, …
原文链接: https://leetcode-cn.com/problems/additive-number 英文原文Additive number is a string whose digits can form additive sequence. A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number …
原文链接: https://leetcode-cn.com/problems/range-sum-query-mutable 英文原文Given an integer array nums, handle multiple queries of the following types: Update the value of an element in nums. Calculate the sum of the elements of nums between indices left and…
原文链接: https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-with-cooldown 英文原文You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete as many tra…
原文链接: https://leetcode-cn.com/problems/minimum-height-trees 英文原文A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree. Given a tree of n nodes la…
原文链接: https://leetcode-cn.com/problems/remove-duplicate-letters 英文原文Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible…
原文链接: https://leetcode-cn.com/problems/maximum-product-of-word-lengths 英文原文Given a string array words, return the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. If no such two words exist, return 0…
原文链接: https://leetcode-cn.com/problems/bulb-switcher 英文原文There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turnin…
原文链接: https://leetcode-cn.com/problems/coin-change 英文原文You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to m…
原文链接: https://leetcode-cn.com/problems/odd-even-linked-list 英文原文Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered…
原文链接: https://leetcode-cn.com/problems/verify-preorder-serialization-of-a-binary-tree 英文原文One way to serialize a binary tree is to use preorder traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record …
原文链接: https://leetcode-cn.com/problems/increasing-triplet-subsequence 英文原文Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k]. If no such indices exists, return fa…
原文链接: https://leetcode-cn.com/problems/house-robber-iii 英文原文The thief has found himself a new place for his thievery again. There is only one entrance to this area, called root. Besides the root, each house has one and only one parent house. After a …
原文链接: https://leetcode-cn.com/problems/flatten-nested-list-iterator 英文原文You are given a nested list of integers nestedList. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an iterator to flatt…
原文链接: https://leetcode-cn.com/problems/integer-break 英文原文Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers. Return the maximum product you can get. Example 1: Input: n = 2 Outpu…
原文链接: https://leetcode-cn.com/problems/top-k-frequent-elements 英文原文Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] …
原文链接: https://leetcode-cn.com/problems/design-twitter 英文原文Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the user's news feed. Implement the Twitter cl…
原文链接: https://leetcode-cn.com/problems/water-and-jug-problem 英文原文You are given two jugs with capacities jug1Capacity and jug2Capacity liters. There is an infinite amount of water supply available. Determine whether it is possible to measure exactly t…
原文链接: https://leetcode-cn.com/problems/sum-of-two-integers 英文原文Given two integers a and b, return the sum of the two integers without using the operators + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2: Input: a = 2, b = 3 Output: 5 Const…
原文链接: https://leetcode-cn.com/problems/super-pow 英文原文Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array. Example 1: Input: a = 2, b = [3] Output: 8 Example 2:…
原文链接: https://leetcode-cn.com/problems/find-k-pairs-with-smallest-sums 英文原文You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u, v) which consists of one element from the first array and one el…
原文链接: https://leetcode-cn.com/problems/guess-number-higher-or-lower-ii 英文原文We are playing the Guessing Game. The game will work as follows: I pick a number between 1 and n. You guess a number. If you guess the right number, you win the game. If you g…
原文链接: https://leetcode-cn.com/problems/wiggle-subsequence 英文原文A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positi…