Skip to content

Commit 5f559c3

Browse files
committed
added array solution
1 parent c7dee70 commit 5f559c3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
|:----:|:--------------------------------------------------------------------:| :---: | :---: |:-----------:|
66
| 1 | [Remove duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/) | [Python solution](python/arrays/RemoveDuplicates.py) | Easy | Arrays |
77
| 2 | [First Unique Character in a String](https://leetcode.com/problems/first-unique-character-in-a-string/) | [Python solution](python/arrays/first-unique-character-in-a-string.py) | Easy | Arrays |
8-
8+
| 3 | [Remove Element](https://leetcode.com/problems/remove-element/) | [Python solution](python/arrays/remove-element.py) | Easy | Arrays |

python/arrays/remove-element.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution(object):
2+
def removeElement(self, nums, val):
3+
"""
4+
:type nums: List[int]
5+
:type val: int
6+
:rtype: int
7+
"""
8+
i = 0
9+
j = len(nums) - 1
10+
11+
for n in nums:
12+
if n != val:
13+
nums[i] = n
14+
i = i + 1
15+

0 commit comments

Comments
 (0)