அல்கோரிதம்filtering
Filtering உடன் two pointers
TT
Testlaa Team
May 14, 2026•1 min read
Filtering: ஒரு scan-ல் rule match இல்லாதவற்றை முன்னே எழுது.
Try this in Python
def remove_value(nums: list[int], val: int) -> int:
w = 0
for x in nums:
if x != val:
nums[w] = x
w += 1
return w
a = [3, 2, 2, 3]
k = remove_value(a, 3)
print(k, a[:k])
Key takeaways
- In-place filtering: read/write pointers.
- Order preserved.
- புதிய length return.
Tags:
Two pointersPythonமாணவர்கள்
