From 54012638fcaa23397cda80ec32c22001317a9719 Mon Sep 17 00:00:00 2001 From: Claude Ni <49127719+ClaudeNi@users.noreply.github.com> Date: Tue, 4 Oct 2022 22:12:10 +0300 Subject: [PATCH] Create removeElement.py --- leetcode/python/removeElement.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 leetcode/python/removeElement.py diff --git a/leetcode/python/removeElement.py b/leetcode/python/removeElement.py new file mode 100644 index 0000000..3af0a77 --- /dev/null +++ b/leetcode/python/removeElement.py @@ -0,0 +1,13 @@ +class Solution(object): + def removeElement(self, nums, val): + """ + :type nums: List[int] + :type val: int + :rtype: int + """ + count = 0 + for i in nums: + if i != val: + nums[count] = i + count = count + 1 + return count