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-3160](https://leetcode.com/problems/find-the-number-of-distinct-colors-among-the-balls/)| Find The Number Of Distinct Colors Among The Balls |[c++](./leetcode/3160.find-the-number-of-distinct-colors-among-the-balls.cpp), [python3](./leetcode/3160.find-the-number-of-distinct-colors-among-the-balls.py)| Simulation | O\(N\)| O\(N\)| - |
|[Leetcode-731](https://leetcode.com/problems/my-calendar-ii/)| My Calendar II |[c++](./leetcode/731.my-calendar-ii.cpp), [python3](./leetcode/731.my-calendar-ii.py)| Binary Search | O\(N\)| O\(N\)| - |
510
511
|[Leetcode-732](https://leetcode.com/problems/my-calendar-iii/)| My Calendar III |[c++](./leetcode/732.my-calendar-iii.cpp), [python3](./leetcode/732.my-calendar-iii.py)| Binary Search | O\(NlogN\)| O\(N\)| - |
511
512
|[Leetcode-2251](https://leetcode.com/problems/number-of-flowers-in-full-bloom/)| Number Of Flowers In Full Bloom |[c++](./leetcode/2251.number-of-flowers-in-full-bloom.cpp), [python3](./leetcode/2251.number-of-flowers-in-full-bloom.py)| Binary Search | O\(NlogN \+ MlogM\)| O\(N \+ M\)| - |
513
+
|[Leetcode-1498](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/)| Number Of Subsequences That Satisfy The Given Sum Condition |[c++](./leetcode/1498.number-of-subsequences-that-satisfy-the-given-sum-condition.cpp), [python3](./leetcode/1498.number-of-subsequences-that-satisfy-the-given-sum-condition.py)| Binary Search | O\(NlogN\)| O\(1\)| - |
|[Leetcode-876](https://leetcode.com/problems/middle-of-the-linked-list/)| Middle Of The Linked List |[c++](./leetcode/876.middle-of-the-linked-list.cpp), [python3](./leetcode/876.middle-of-the-linked-list.py)| Two Pointers | O\(N\)| O\(1\)| - |
895
897
|[Leetcode-1750](https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends/)| Minimum Length Of String After Deleting Similar Ends |[c++](./leetcode/1750.minimum-length-of-string-after-deleting-similar-ends.cpp), [python3](./leetcode/1750.minimum-length-of-string-after-deleting-similar-ends.py)| Two Pointers | O\(N\)| O\(1\)| - |
896
898
|[Leetcode-1040](https://leetcode.com/problems/moving-stones-until-consecutive-ii/)| Moving Stones Until Consecutive II |[c++](./leetcode/1040.moving-stones-until-consecutive-ii.cpp), [python3](./leetcode/1040.moving-stones-until-consecutive-ii.py)| Two Pointers | O\(NlogN\)| O\(1\)| - |
899
+
|[Leetcode-1498](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/)| Number Of Subsequences That Satisfy The Given Sum Condition |[c++](./leetcode/1498.number-of-subsequences-that-satisfy-the-given-sum-condition.cpp), [python3](./leetcode/1498.number-of-subsequences-that-satisfy-the-given-sum-condition.py)| Two Pointers | O\(NlogN\)| O\(1\)| - |
897
900
|[Leetcode-1577](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/)| Number Of Ways Where Square Of Number Is Equal To Product Of Two Numbers |[c++](./leetcode/1577.number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers.cpp), [python3](./leetcode/1577.number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers.py)| Two Pointers | O\(NM\)| O\(N \+ M\)| - |
898
901
|[Leetcode-234](https://leetcode.com/problems/palindrome-linked-list/)| Palindrome Linked List |[c++](./leetcode/234.palindrome-linked-list.cpp), [python3](./leetcode/234.palindrome-linked-list.py)| Two Pointers | O\(N\)| O\(1\)| - |
|[Leetcode-2251](https://leetcode.com/problems/number-of-flowers-in-full-bloom/)| Number Of Flowers In Full Bloom |[c++](./leetcode/2251.number-of-flowers-in-full-bloom.cpp), [python3](./leetcode/2251.number-of-flowers-in-full-bloom.py)| Sorting | O\(NlogN \+ MlogM\)| O\(N \+ M\)| - |
1089
+
|[Leetcode-1498](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/)| Number Of Subsequences That Satisfy The Given Sum Condition |[c++](./leetcode/1498.number-of-subsequences-that-satisfy-the-given-sum-condition.cpp), [python3](./leetcode/1498.number-of-subsequences-that-satisfy-the-given-sum-condition.py)| Sorting | O\(NlogN\)| O\(1\)| - |
1086
1090
|[Leetcode-1976](https://leetcode.com/problems/number-of-ways-to-arrive-at-destination/)| Number Of Ways To Arrive At Destination |[c++](./leetcode/1976.number-of-ways-to-arrive-at-destination.cpp), [python3](./leetcode/1976.number-of-ways-to-arrive-at-destination.py)| Sorting | O\(\(E \+ V\)logV\)| O\(E \+ V\)| - |
1087
1091
|[Leetcode-2551](https://leetcode.com/problems/put-marbles-in-bags/)| Put Marbles In Bags |[c++](./leetcode/2551.put-marbles-in-bags.cpp), [python3](./leetcode/2551.put-marbles-in-bags.py)| Sorting | O\(N\)| O\(N\)| - |
// Tag: Array, Two Pointers, Binary Search, Sorting
2
+
// Time: O(NlogN)
3
+
// Space: O(1)
4
+
// Ref: -
5
+
// Note: -
6
+
7
+
// You are given an array of integers nums and an integer target.
8
+
// Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.
9
+
//
10
+
// Example 1:
11
+
//
12
+
// Input: nums = [3,5,6,7], target = 9
13
+
// Output: 4
14
+
// Explanation: There are 4 subsequences that satisfy the condition.
15
+
// [3] -> Min value + max value <= target (3 + 3 <= 9)
16
+
// [3,5] -> (3 + 5 <= 9)
17
+
// [3,5,6] -> (3 + 6 <= 9)
18
+
// [3,6] -> (3 + 6 <= 9)
19
+
//
20
+
// Example 2:
21
+
//
22
+
// Input: nums = [3,3,6,8], target = 10
23
+
// Output: 6
24
+
// Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).
25
+
// [3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]
26
+
//
27
+
// Example 3:
28
+
//
29
+
// Input: nums = [2,3,3,4,6,7], target = 12
30
+
// Output: 61
31
+
// Explanation: There are 63 non-empty subsequences, two of them do not satisfy the condition ([6,7], [7]).
# Tag: Array, Two Pointers, Binary Search, Sorting
2
+
# Time: O(NLogN)
3
+
# Space: O(1)
4
+
# Ref: -
5
+
# Note: -
6
+
7
+
# You are given an array of integers nums and an integer target.
8
+
# Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.
9
+
#
10
+
# Example 1:
11
+
#
12
+
# Input: nums = [3,5,6,7], target = 9
13
+
# Output: 4
14
+
# Explanation: There are 4 subsequences that satisfy the condition.
15
+
# [3] -> Min value + max value <= target (3 + 3 <= 9)
16
+
# [3,5] -> (3 + 5 <= 9)
17
+
# [3,5,6] -> (3 + 6 <= 9)
18
+
# [3,6] -> (3 + 6 <= 9)
19
+
#
20
+
# Example 2:
21
+
#
22
+
# Input: nums = [3,3,6,8], target = 10
23
+
# Output: 6
24
+
# Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).
25
+
# [3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]
26
+
#
27
+
# Example 3:
28
+
#
29
+
# Input: nums = [2,3,3,4,6,7], target = 12
30
+
# Output: 61
31
+
# Explanation: There are 63 non-empty subsequences, two of them do not satisfy the condition ([6,7], [7]).
// Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.
9
+
// A zero-based permutation nums is an array of distinct integers from 0 to nums.length - 1 (inclusive).
10
+
//
11
+
// Example 1:
12
+
//
13
+
// Input: nums = [0,2,1,5,3,4]
14
+
// Output: [0,1,2,4,5,3]
15
+
// Explanation: The array ans is built as follows:
16
+
// ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]
# Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.
9
+
# A zero-based permutation nums is an array of distinct integers from 0 to nums.length - 1 (inclusive).
10
+
#
11
+
# Example 1:
12
+
#
13
+
# Input: nums = [0,2,1,5,3,4]
14
+
# Output: [0,1,2,4,5,3]
15
+
# Explanation: The array ans is built as follows:
16
+
# ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]
0 commit comments