原文链接: https://leetcode-cn.com/problems/get-equal-substrings-within-budget 英文原文You are given two strings s and t of the same length. You want to change s to t. Changing the i-th character of s to i-th character of t costs |s[i] - t[i]| that is, the ab…
标签详情
滑动窗口 分类
原文链接: https://leetcode-cn.com/problems/replace-the-substring-for-balanced-string 英文原文You are given a string containing only 4 kinds of characters 'Q', 'W', 'E' and 'R'. A string is said to be balanced if each of its characters appears n/4 times where…
原文链接: 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/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/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold 英文原文Given an array of integers arr and two integers k and threshold. Return the number of sub-arrays of size k and average greater th…
原文链接: 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/maximum-points-you-can-obtain-from-cards 英文原文There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints. In one step, you ca…
原文链接: https://leetcode-cn.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit 英文原文Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute diffe…
原文链接: https://leetcode-cn.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length 英文原文Given a string s and an integer k. Return the maximum number of vowel letters in any substring of s with length k. Vowel letters in English are (a, e, …
原文链接: https://leetcode-cn.com/problems/longest-subarray-of-1s-after-deleting-one-element 英文原文Given a binary array nums, you should delete one element from it. Return the size of the longest non-empty subarray containing only 1's in the resulting arra…
原文链接: https://leetcode-cn.com/problems/max-value-of-equation 英文原文You are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <= points.lengt…
原文链接: https://leetcode-cn.com/problems/maximum-number-of-visible-points 英文原文You are given an array points, an integer angle, and your location, where location = [posx, posy] and points[i] = [xi, yi] both denote integral coordinates on the X-Y plane. …
原文链接: https://leetcode-cn.com/problems/minimum-operations-to-reduce-x-to-zero 英文原文You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subtract its…
原文链接: https://leetcode-cn.com/problems/substrings-of-size-three-with-distinct-characters 英文原文A string is good if there are no repeated characters. Given a string s, return the number of good substrings of length three in s. Note that if th…
原文链接: https://leetcode-cn.com/problems/maximize-the-confusion-of-an-exam 英文原文A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing the number of consecut…
原文链接: https://leetcode-cn.com/problems/k-radius-subarray-averages 英文原文You are given a 0-indexed array nums of n integers, and an integer k. The k-radius average for a subarray of nums centered at some index i with the radius k is the average of all e…
原文链接: https://leetcode-cn.com/problems/zui-chang-bu-han-zhong-fu-zi-fu-de-zi-zi-fu-chuan-lcof 中文题目请从字符串中找出一个最长的不包含重复字符的子字符串,计算该最长子字符串的长度。 示例 1: 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 示例 2: 输入: "bbbbb" 输出: 1 解释: 因为无重复字符的最长子串是 "b",所以其长度…
原文链接: https://leetcode-cn.com/problems/multi-search-lcci 英文原文Given a string band an array of smaller strings T, design a method to search b for each small string in T. Output positions of all strings in smalls that appear in big, where positions[i] i…
原文链接: https://leetcode-cn.com/problems/shortest-supersequence-lcci 英文原文You are given two arrays, one shorter (with all distinct elements) and one longer. Find the shortest subarray in the longer array that contains all the elements in the shorter arr…
原文链接: https://leetcode-cn.com/problems/2VG8Kg 中文题目给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其和 ≥ target 的长度最小的 连续子数组 [numsl, numsl+1, ..., numsr-1, numsr] ,并返回其长度。如果不存在符合条件的子数组,返回 0 。 示例 1: 输入:target = 7, nums = [2,3,1,2,4,3] 输出:2 解释:子数组 [4,3] 是该条件下…
原文链接: https://leetcode-cn.com/problems/ZVAVXX 中文题目给定一个正整数数组 nums和整数 k ,请找出该数组内乘积小于 k 的连续的子数组的个数。 示例 1: 输入: nums = [10,5,2,6], k = 100 输出: 8 解释: 8 个乘积小于 100 的子数组分别为: [10], [5], [2], [6], [10,5], [5,2], [2,6], [5,2,6]。 需要注意的是 [10,5,2] 并不是乘积小于100的子数组。 示…
原文链接: https://leetcode-cn.com/problems/MPnaiL 中文题目给定两个字符串 s1 和 s2,写一个函数来判断 s2 是否包含 s1 的某个变位词。 换句话说,第一个字符串的排列之一是第二个字符串的 子串 。 示例 1: 输入: s1 = "ab" s2 = "eidbaooo" 输出: True 解释: s2 包含 s1 的排列之一 ("ba"). 示例 2: 输入: s1= "ab" s2 = "eidboaoo" 输出: False 提示: 1 <= …
原文链接: https://leetcode-cn.com/problems/VabMRr 中文题目给定两个字符串 s 和 p,找到 s 中所有 p 的 变位词 的子串,返回这些子串的起始索引。不考虑答案输出的顺序。 变位词 指字母相同,但排列不同的字符串。 示例 1: 输入: s = "cbaebabacd", p = "abc" 输出: [0,6] 解释: 起始索引等于 0 的子串是 "cba", 它是 "abc" 的变位词。 起始索引等于 6 的子串是 "bac", 它是 "abc" 的变…
原文链接: https://leetcode-cn.com/problems/wtcaE1 中文题目给定一个字符串 s ,请你找出其中不含有重复字符的 最长连续子字符串 的长度。 示例 1: 输入: s = "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子字符串是 "abc",所以其长度为 3。 示例 2: 输入: s = "bbbbb" 输出: 1 解释: 因为无重复字符的最长子字符串是 "b",所以其长度为 1。 示例 3: 输入: s = "pwwkew" 输出: 3 解释…
原文链接: https://leetcode-cn.com/problems/M1oyTv 中文题目给定两个字符串 s 和 t 。返回 s 中包含 t 的所有字符的最短子字符串。如果 s 中不存在符合条件的子字符串,则返回空字符串 "" 。 如果 s 中存在多个符合条件的子字符串,返回任意一个。 注意: 对于 t 中重复字符,我们寻找的子字符串中该字符数量必须不少于 t 中该字符数量。 示例 1: 输入:s = "ADOBECODEBANC", t = "ABC" 输出:"BANC" 解释:最短…
原文链接: https://leetcode-cn.com/problems/7WqeDu 中文题目给你一个整数数组 nums 和两个整数 k 和 t 。请你判断是否存在 两个不同下标 i 和 j,使得 abs(nums[i] - nums[j]) <= t ,同时又满足 abs(i - j) <= k 。 如果存在则返回 true,不存在返回 false。 示例 1: 输入:nums = [1,2,3,1], k = 3, t = 0 输出:true 示例 2: 输入:nums = [1,0,…
上一页
2 / 2