Input: K = 2 Output: -1 Explanation: There is no such positive integer N divisible by 2. 1 2 3 Example 3: Input: K = 3 Output: 3 Explanation: The smallest answer is N = 111, which has length 3. 1 2 3 Constraints: 1 <= K <= 105 分析 题目的意思是:给定数K,求最小的数...
Explanation: The two lists do not intersect, so return null. Constraints: The number of nodes of listA is in the m. The number of nodes of listB is in the n. 1 <= m, n <= 3 * 104 1 <= Node.val <= 105 0 <= skipA < m 0 <= skipB < n intersectVal is 0 if listA ...
本文链接:https://blog.csdn.net/grllery/article/details/97814716智能推荐[leetcode]632. Smallest Range 题目链接:https://leetcode.com/problems/smallest-range/description/ You have k lists of sorted integers in ascending order. Find the smallest range that includes at least one number fro...lee...
Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: "pwwkew" Output: 3 Explanation: The answer is "wke", with the length...
-105 <= nums[i] <= 105 二、反思 1.自己的解法 class Solution { public: bool isMonotonic(vector<int>& nums) { int n=nums.size(); int index_1=0; int index_2=0; for (int i=0;i<n-1;i++){ if(nums[i]<nums[i+1]){ index_1++; }else if(nums[i]>nums[i+1]){ index_...
Input: head = [4,5,1,9], node = 1 Output: [4,5,9] Explanation: You are given the third node with value 1, the linked list should become 4 -> 5 -> 9 after calling your function. 1 2 3 Example 3: Input: head = [1,2,3,4], node = 3 Output: [1,2,4] 1 2 Example...
参考: https://leetcode.com/problems/minimum-window-substring/discuss/26840/Sharing-my-straightforward-O(n)-solution-with-explanation 代码其实看的不太懂 思路: https://blog.csdn.net/zhangxiao93/article/details/49892...LeetCode 76. 最小覆盖子串 给你一个字符串 S、一个字符串 T,请在字符串 S...
Explanation: The final subarray needs to be non-empty. You can't choose [-1] and delete -1 from it, then get an empty subarray to make the sum equals to 0. Constraints: 1 <= arr.length <= 105 -104 <= arr[i] <= 104 题目链接:https://leetcode.com/problems/maximum-subarray-sum...
Explanation: A permutation with the max total sum is [4,10,5,3,2,1] with request sums [19,18,10]. Constraints: n == nums.length 1 <= n <= 105 0 <= nums[i] <= 105 1 <= requests.length <= 105 requests[i].length == 2 0 <= starti <= endi < n 题目链接:https://le...
参考: https://leetcode.com/problems/minimum-window-substring/discuss/26840/Sharing-my-straightforward-O(n)-solution-with-explanation 代码其实看的不太懂 思路: https://blog.csdn.net/zhangxiao93/article/details/49892...LeetCode 76. 最小覆盖子串 给你一个字符串 S、一个字符串 T,请在字符串 S...