You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[Leetcode-3272](https://leetcode.com/problems/find-the-count-of-good-integers/)| Find The Count Of Good Integers |[c++](./leetcode/3272.find-the-count-of-good-integers.cpp), [python3](./leetcode/3272.find-the-count-of-good-integers.py)| Enumeration | O\(10\*\*\(N/2\)\* NlogN\)| O\(10\*\*\(N/2\)\)| - |
261
261
|[Leetcode-3411](https://leetcode.com/problems/maximum-subarray-with-equal-products/)| Maximum Subarray With Equal Products |[c++](./leetcode/3411.maximum-subarray-with-equal-products.cpp), [python3](./leetcode/3411.maximum-subarray-with-equal-products.py)| Enumeration | O\(N \* sqrt\(Num\)\)| O\(N\)| - |
262
262
|[Leetcode-1863](https://leetcode.com/problems/sum-of-all-subset-xor-totals/)| Sum Of All Subset Xor Totals |[c++](./leetcode/1863.sum-of-all-subset-xor-totals.cpp), [python3](./leetcode/1863.sum-of-all-subset-xor-totals.py)| Enumeration | O\(N\)| O\(1\)| - |
|[Leetcode-1589](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation/)| Maximum Sum Obtained Of Any Permutation |[c++](./leetcode/1589.maximum-sum-obtained-of-any-permutation.cpp), [python3](./leetcode/1589.maximum-sum-obtained-of-any-permutation.py)| Greedy | O\(NlogN\)| O\(N\)| - |
328
329
|[Leetcode-2271](https://leetcode.com/problems/maximum-white-tiles-covered-by-a-carpet/)| Maximum White Tiles Covered By A Carpet |[c++](./leetcode/2271.maximum-white-tiles-covered-by-a-carpet.cpp), [python3](./leetcode/2271.maximum-white-tiles-covered-by-a-carpet.py)| Greedy | O\(NlogN\)| O\(1\)| - |
|[Leetcode-2918](https://leetcode.com/problems/minimum-equal-sum-of-two-arrays-after-replacing-zeros/)| Minimum Equal Sum Of Two Arrays After Replacing Zeros |[c++](./leetcode/2918.minimum-equal-sum-of-two-arrays-after-replacing-zeros.cpp), [python3](./leetcode/2918.minimum-equal-sum-of-two-arrays-after-replacing-zeros.py)| Greedy | O\(N\)| O\(1\)| - |
330
332
|[Leetcode-452](https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/)| Minimum Number Of Arrows To Burst Balloons |[c++](./leetcode/452.minimum-number-of-arrows-to-burst-balloons.cpp), [python3](./leetcode/452.minimum-number-of-arrows-to-burst-balloons.py)| Greedy | O\(NlogN\)| O\(1\)| - |
331
333
|[Leetcode-1888](https://leetcode.com/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/)| Minimum Number Of Flips To Make The Binary String Alternating |[c++](./leetcode/1888.minimum-number-of-flips-to-make-the-binary-string-alternating.cpp), [python3](./leetcode/1888.minimum-number-of-flips-to-make-the-binary-string-alternating.py)| Greedy | O\(N\)| O\(1\)| - |
332
334
|[Leetcode-1326](https://leetcode.com/problems/minimum-number-of-taps-to-open-to-water-a-garden/)| Minimum Number Of Taps To Open To Water A Garden |[c++](./leetcode/1326.minimum-number-of-taps-to-open-to-water-a-garden.cpp), [python3](./leetcode/1326.minimum-number-of-taps-to-open-to-water-a-garden.py)| Greedy | O\(N\)| O\(N\)| - |
|[Lintcode-617](https://www.lintcode.com/problem/maximum-average-subarray-ii/)| Maximum Average Subarray II |[c++](./lintcode/617.maximum-average-subarray-ii.cpp), [python3](./lintcode/617.maximum-average-subarray-ii.py)| Binary Search | O\(Nlog\(A/ε\)\)| O\(N\)| Leetcode-644 |
541
544
|[Lintcode-585](https://www.lintcode.com/problem/maximum-number-in-mountain-sequence/)| Maximum Number In Mountain Sequence |[c++](./lintcode/585.maximum-number-in-mountain-sequence.cpp), [python3](./lintcode/585.maximum-number-in-mountain-sequence.py)| Binary Search | O\(logN\)| O\(1\)| - |
|[Lintcode-3630](https://www.lintcode.com/problem/two-sum-less-than-target/)| Two Sum Less Than Target |[c++](./lintcode/3630.two-sum-less-than-target.cpp), [python3](./lintcode/3630.two-sum-less-than-target.py)| Binary Search | O\(NlogN\)| O\(1\)| Leetcode-1099 |
|[Leetcode-611](https://leetcode.com/problems/valid-triangle-number/)| Valid Triangle Number |[c++](./leetcode/611.valid-triangle-number.cpp), [python3](./leetcode/611.valid-triangle-number.py)| Two Pointers | O\(N^2\)| O\(1\)| - |
923
927
|[Leetcode-2105](https://leetcode.com/problems/watering-plants-ii/)| Watering Plants II |[c++](./leetcode/2105.watering-plants-ii.cpp), [python3](./leetcode/2105.watering-plants-ii.py)| Two Pointers | O\(N\)| O\(1\)| - |
924
928
|[Leetcode-1712](https://leetcode.com/problems/ways-to-split-array-into-three-subarrays/)| Ways To Split Array Into Three Subarrays |[c++](./leetcode/1712.ways-to-split-array-into-three-subarrays.cpp), [python3](./leetcode/1712.ways-to-split-array-into-three-subarrays.py)| Two Pointers | O\(N\)| O\(N\)| - |
|[Lintcode-861](https://www.lintcode.com/problem/k-empty-slots/)| K Empty Slots |[c++](./lintcode/861.k-empty-slots.cpp), [python3](./lintcode/861.k-empty-slots.py)| Two Pointers | O\(N\)| O\(N\)| Leetcode-683 |
926
931
|[Lintcode-3736](https://www.lintcode.com/problem/kth-smallest-subarray-sum/)| Kth Smallest Subarray Sum |[c++](./lintcode/3736.kth-smallest-subarray-sum.cpp), [python3](./lintcode/3736.kth-smallest-subarray-sum.py)| Two Pointers | O\(NlogA\)| O\(1\)| Leetcode-1918 |
927
932
|[Lintcode-386](https://www.lintcode.com/problem/longest-substring-with-at-most-k-distinct-characters/)| Longest Substring With At Most K Distinct Characters |[c++](./lintcode/386.longest-substring-with-at-most-k-distinct-characters.cpp), [python3](./lintcode/386.longest-substring-with-at-most-k-distinct-characters.py)| Two Pointers | O\(N\)| O\(K\)| Leetcode-340 |
928
933
|[Lintcode-928](https://www.lintcode.com/problem/longest-substring-with-at-most-two-distinct-characters/)| Longest Substring With At Most Two Distinct Characters |[c++](./lintcode/928.longest-substring-with-at-most-two-distinct-characters.cpp), [python3](./lintcode/928.longest-substring-with-at-most-two-distinct-characters.py)| Two Pointers | O\(N\)| O\(1\)| Leetcode-159 |
929
934
|[Lintcode-883](https://www.lintcode.com/problem/max-consecutive-ones-ii/)| Max Consecutive Ones II |[c++](./lintcode/883.max-consecutive-ones-ii.cpp), [python3](./lintcode/883.max-consecutive-ones-ii.py)| Two Pointers | O\(N\)| O\(1\)| Leetcode-487 |
|[Lintcode-3827](https://www.lintcode.com/problem/merge-operations-to-turn-array-into-a-palindrome/)| Merge Operations To Turn Array Into A Palindrome |[c++](./lintcode/3827.merge-operations-to-turn-array-into-a-palindrome.cpp), [python3](./lintcode/3827.merge-operations-to-turn-array-into-a-palindrome.py)| Two Pointers | O\(N\)| O\(1\)| - |
937
+
|[Lintcode-3630](https://www.lintcode.com/problem/two-sum-less-than-target/)| Two Sum Less Than Target |[c++](./lintcode/3630.two-sum-less-than-target.cpp), [python3](./lintcode/3630.two-sum-less-than-target.py)| Two Pointers | O\(NlogN\)| O\(1\)| Leetcode-1099 |
// Given an array of integers `nums` and an integer `target`, if there exists `i < j` such that `nums[i] + nums[j] < target`, then return **the maximum and that satisfy this condition**.
8
+
// If no `i, j` satisfying the above condition exists, then `-1` is returned.
9
+
//
10
+
// Example 1:
11
+
// ```
12
+
// Input:
13
+
// nums = [2, 7, 11, 15], target = 24
14
+
// Output:
15
+
// 22
16
+
// Explanation:
17
+
// 7 + 15 = 22 < 24
18
+
// 11 + 15 = 26 > 24
19
+
// 22 is the maximum sum that satisfies the condition
20
+
// ```
21
+
//
22
+
// Example 2:
23
+
// ```
24
+
// Input:
25
+
// nums = [3, 5, 1, 9, 7], target = 3
26
+
// Output:
27
+
// -1
28
+
// Explanation:
29
+
// Cannot find two elements whose sum is less than 3
30
+
// ```
31
+
//
32
+
// $1 \leq nums.length \leq 1000$
33
+
// $-1000 \leq nums[i] \leq 1000$
34
+
// $-2000 \leq target \leq 2000$
35
+
36
+
classSolution {
37
+
public:
38
+
/**
39
+
* @param nums: An array of integer
40
+
* @param target: An integer
41
+
* @return: The sum of two numbers smaller than target
42
+
*/
43
+
inttwoSumLessThanTarget(vector<int> &nums, int target) {
0 commit comments