DEV Community

Victor Joseph
Victor Joseph

Posted on

Remove Element

class Solution:
    def removeElement(self, nums: List[int], val: int) -> int:
        while val in nums:
            nums.remove(val)
Enter fullscreen mode Exit fullscreen mode

Day 2 of 10. Leet code problem can be found here

I looped through the entire array while checking if the val is in the array. if it is found, i remove that particular value.

tada :)

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay