Skip to content

Commit 7d9a9e7

Browse files
authored
Merge pull request #5 from SaykoMe/sayko-solutions
Sayko solutions
2 parents 0278185 + bb83951 commit 7d9a9e7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Python/remove_element.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Remove Element
2+
3+
class Solution(object):
4+
def removeElement(self, nums, val):
5+
left, right = 0, len(nums) - 1
6+
7+
while left <= right:
8+
if nums[left] == val:
9+
nums[left], nums[right] = nums[right], nums[left]
10+
right -= 1
11+
else:
12+
left += 1
13+
14+
return left
15+
16+
solution = Solution()
17+
print(solution.removeElement([3,2,2,3], 3))

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
227227
- [First Missing Positive](Python/first_missing_positive.py)
228228
- [Subarray Product Less Than K](Python/subarray_product_less_than_k.py)
229229
- [Valid Parentheses](Python/valid_parentheses.py)
230+
- [Remove Element](Python/remove_element.py)

0 commit comments

Comments
 (0)