https://leetcode.com/problems/longest-repeating-character-replacement/ 2. Pattern: two points,双指针类型 双指针是这样的模式:两个指针朝着左右方向移动(双指针分为同向双指针和异向双指针),直到他们有一个或是两个都满足某种条件。双指针通常用在排好序的数组或是链表中寻找对子。比如,你需要去比较数组中...
371 Sum of Two Integers Easy 54.00% 372 Super Pow Medium 30.10% 373 Find K Pairs with Smallest Sums Medium 25.50% 374 Guess Number Higher or Lower Easy 31.70% 375 Guess Number Higher or Lower II Medium 28.30% 376 Wiggle Subsequence Medium 35.80% 377 Combination Sum IV Medium 37.50% 378 K...
1347 Minimum Number of Steps to Make Two Strings Anagram Medium Python 1351 Count Negative Numbers in a Sorted Matrix Easy Python 1352 Product of the Last K Numbers Medium Python 1354 Construct Target Array With Multiple Sums Hard Go 1356 Sort Integers by The Number of 1 Bits Easy Python 1359...
Given a special string S, a move consists of choosing two consecutive, non-empty, special substrings of S, and swapping them. (Two strings are consecutive if the last character of the first string is exactly one index before the first character of the second string.) At the end of any ...
All Questions with innovative solutions LeetCode Topics String 0874-backspace-string-compare 1651-shuffle-string 3174-minimum-number-of-changes-to-make-binary-string-beautiful Array 0001-two-sum 0016-3sum-closest 0026-remove-duplicates-from-sorted-array 0122-best-time-to-buy-and-sell-stock-ii 0189...
Two questions use the same idea, recursion and backtracking, when target hit 0, record the result. The combination sum allows unlimited duplicates while the other limits the duplicates numbers. Notice we always need to avoid duplicates by counting the number of same elements in the recursion for...
Sum of Two Integers Easy 247 372. Super Pow Medium 247 373. Find K Pairs with Smallest Sums Medium 248 374. Guess Number Higher or Lower Easy 249 375. Guess Number Higher or Lower II Medium 250 376. Wiggle Subsequence Medium 250 377. Combination Sum IV Medium 251 378. Kth Smallest ...
//https://math.stackexchange.com/questions/113270/the-median-minimizes-the-sum-of-absolute-deviations-the-l-1-norm class Solution { public: int minMoves2(vector<int>& nums) { if(nums.empty())return 0; sort(nums.begin(),nums.end()); int medium=0; if(nums.size()%2==0){ medium=(...
0371 Sum of Two Integers Go 50.7% Medium 0372 Super Pow Go 36.4% Medium 0373 Find K Pairs with Smallest Sums Go 36.7% Medium 0374 Guess Number Higher or Lower 43.0% Easy 0375 Guess Number Higher or Lower II 40.3% Medium 0376 Wiggle Subsequence 39.6% Medium 0377 Combination Sum ...
Questions to Ask the Interviewer: Can I assume that there will always be at least one duplicate in the array? Can I assume that the numbers are always positive and within the range 1 ton? Edge Cases: Case where all elements are the same. For example,nums = [2,2,2,2]. ...