feat(work): add 901 online stock span solution and implement removeDuplicates algorithm

This commit is contained in:
Prad Nukala committed 2026-10-06 13:47:23 -04:00
1 parent a3e846c606
commit 598688977a
2 files changed
+88 -6

No files matched your search

@@ -37,7 +37,7 @@ for (int i = 0; i < k; i++) {
If all assertions pass, then your solution will be accepted.
Example 1:
@@ -57,17 +57,23 @@ elements of nums being 0, 0, 1, 1, 2, 3 and 3 respectively.
It does not matter what you leave beyond the returned k (hence they
are underscores).
Constraints:
• 1 <= nums.length <= 3 * 10^4
• 1 <= nums.length <= 3 * 10^4
• -10^4 <= nums[i] <= 10^4
• -10^4 <= nums[i] <= 10^4
• nums is sorted in non-decreasing order.
• nums is sorted in non-decreasing order.
"""
class Solution:
def removeDuplicates(self, nums: list[int]) -> int:
slow = 0
for fast in range(len(nums)):
if slow < 2 or nums[fast] != nums[slow - 2]:
nums[slow] = nums[fast]
slow += 1
return slow