Skip to content

Commit 4adfb17

Browse files
committed
Mar 1
1 parent 7f8db2b commit 4adfb17

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Solution:
2+
def applyOperations(self, nums: list[int]) -> list[int]:
3+
n, j = len(nums), 0
4+
for i in range(n):
5+
if i + 1 < n and nums[i] == nums[i+1]:
6+
nums[i] *= 2
7+
nums[i+1] = 0
8+
if nums[i] != 0:
9+
nums[i], nums[j] = nums[j], nums[i]
10+
j += 1
11+
return nums
12+
13+
14+
def main():
15+
nums = [1, 2, 2, 1, 1, 0]
16+
assert Solution().applyOperations(nums) == [1, 4, 2, 0, 0, 0]
17+
18+
nums = [0, 1]
19+
assert Solution().applyOperations(nums) == [1, 0]
20+
21+
22+
if __name__ == '__main__':
23+
main()
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# March-LeetCoding-Challenge-2025
2+
3+
4+
## Questions
5+
| Day | Problem | Level | Status |
6+
| --- | --- | --- | --- |
7+
| March 01 | [2460. Apply Operations to an Array](https://leetcode.com/problems/apply-operations-to-an-array/) | Easy | Solved |
8+
| March 02 | []() | | |
9+
| March 03 | []() | | |
10+
| March 04 | []() | | |
11+
| March 05 | []() | | |
12+
| March 06 | []() | | |
13+
| March 07 | []() | | |
14+
| March 08 | []() | | |
15+
| March 09 | []() | | |
16+
| March 10 | []() | | |
17+
| March 11 | []() | | |
18+
| March 12 | []() | | |
19+
| March 13 | []() | | |
20+
| March 14 | []() | | |
21+
| March 15 | []() | | |
22+
| March 16 | []() | | |
23+
| March 17 | []() | | |
24+
| March 18 | []() | | |
25+
| March 19 | []() | | |
26+
| March 20 | []() | | |
27+
| March 21 | []() | | |
28+
| March 22 | []() | | |
29+
| March 23 | []() | | |
30+
| March 24 | []() | | |
31+
| March 25 | []() | | |
32+
| March 26 | []() | | |
33+
| March 27 | []() | | |
34+
| March 28 | []() | | |
35+
| March 29 | []() | | |
36+
| March 30 | []() | | |
37+
| March 31 | []() | | |
38+
39+
40+
## Summary
41+
| Level | Problems | Solved | Unsolved |
42+
| --- | --- | --- | --- |
43+
| Easy | 1 | 1 | 0 |
44+
| Medium | 0 | 0 | 0 |
45+
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)