Skip to content

Instantly share code, notes, and snippets.

@twsiyuan
Created October 30, 2018 17:49
Show Gist options
  • Save twsiyuan/6bb1ab33485913d029d5a8f5e444d9cc to your computer and use it in GitHub Desktop.
Save twsiyuan/6bb1ab33485913d029d5a8f5e444d9cc to your computer and use it in GitHub Desktop.
LeetCode #27
# https://leetcode.com/problems/remove-element/
class Solution:
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
run = 0
for num in nums:
if num != val:
nums[run] = num
run = run + 1
return run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment