输入:nums = [2,7,11,15], target = 9输出:[0,1]解释:因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。 示例2: 输入:nums = [3,2,4], target = 6输出:[1,2] 示例3: 输入:nums = [3,3], target = 6输出:[0,1] 提示: ...
414. 第三大的数 - 给你一个非空数组,返回此数组中 第三大的数 。如果不存在,则返回数组中最大的数。 示例 1: 输入:[3, 2, 1] 输出:1 解释:第三大的数是 1 。 示例 2: 输入:[1, 2] 输出:2 解释:第三大的数不存在, 所以返回最大的数 2 。 示例 3: 输
https://leetcode.cn/problems/maximize-the-number-of-partitions-after-operations 这道题由于rejudge受害面较广,曾经在零神大数据短暂登顶。常规解法前后缀分解确实思路和实现细节都很变态,但这题有个实现非常简单的状态压缩+记忆化搜索做法。这个做法看上去复杂度至少有2^26级别,很容易认为极不靠谱而直接放弃。但...
https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string/ https://leetcode.com/problems/fruit-into-baskets/ https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/ https://leetcode.com/problems/longest-substring-without-repeating-characters/ http...
Can you solve this real interview question? Number of Recent Calls - You have a RecentCounter class which counts the number of recent requests within a certain time frame. Implement the RecentCounter class: * RecentCounter() Initializes the counter wi
https://leetcode.cn/problems/number-of-matching-subsequences/ Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s. A subsequence of a string is a new string generated from the original string with some characters (can be none) delete...
isSquare(n)) return 1; // enumeration to check if the number can be decomposed into sum of two squares. for (int i = 1; i * i <= n; ++i) { if (this.isSquare(n - i * i)) return 2; } // bottom case of three-square theorem. return 3; } } 复杂度分析...
https://leetcode-cn.com/problems/number-of-connected-components-in-an-undirected-graph/ Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph. ...
https://leetcode-cn.com/problems/max-points-on-a-line/ Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 题意 给定一个二维平面,平面上有 n 个点,求最多有多少个点在同一条直线上。
Can you solve this real interview question? Number of Longest Increasing Subsequence - Given an integer array nums, return the number of longest increasing subsequences. Notice that the sequence has to be strictly increasing. Example 1: Input: num