Skip to content

Commit d3ea859

Browse files
committed
Mar 3
1 parent 16bc40b commit d3ea859

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution:
2+
def pivotArray(self, nums: list[int], pivot: int) -> list[int]:
3+
lesser, equal, greater = [], [], []
4+
for num in nums:
5+
if num < pivot:
6+
lesser.append(num)
7+
elif num == pivot:
8+
equal.append(num)
9+
else:
10+
greater.append(num)
11+
return lesser + equal + greater
12+
13+
14+
def main():
15+
nums = [9, 12, 5, 10, 14, 3, 10]
16+
pivot = 10
17+
assert Solution().pivotArray(nums, pivot) == [9, 5, 3, 10, 10, 12, 14]
18+
19+
nums = [-3, 4, 3, 2]
20+
pivot = 2
21+
assert Solution().pivotArray(nums, pivot) == [-3, 2, 4, 3]
22+
23+
24+
if __name__ == '__main__':
25+
main()

2025-03-March-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
| --- | --- | --- | --- |
77
| March 01 | [2460. Apply Operations to an Array](https://leetcode.com/problems/apply-operations-to-an-array/) | Easy | Solved |
88
| March 02 | [2570. Merge Two 2D Arrays by Summing Values](https://leetcode.com/problems/merge-two-2d-arrays-by-summing-values/) | Easy | Solved |
9-
| March 03 | []() | | |
9+
| March 03 | [2161. Partition Array According to Given Pivot](https://leetcode.com/problems/partition-array-according-to-given-pivot/) | Medium | Solved |
1010
| March 04 | []() | | |
1111
| March 05 | []() | | |
1212
| March 06 | []() | | |
@@ -41,5 +41,5 @@
4141
| Level | Problems | Solved | Unsolved |
4242
| --- | --- | --- | --- |
4343
| Easy | 2 | 2 | 0 |
44-
| Medium | 0 | 0 | 0 |
44+
| Medium | 1 | 1 | 0 |
4545
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)