# leetcode27

Remove Element

*Given an array and a value, remove all instances of that value in place and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.
The order of elements can be changed. It doesn’t matter what you leave beyond the new length.
Example:
Given input array nums = [3,2,2,3], val = 3
Your function should return length = 2, with the first two elements of nums being 2.*

class Solution(object):

def removeElement(self,nums, val):
while 1:
try:
nums.pop(nums.index(val))
except:
return len(nums)

class Solution(object):

def removeElement(self,nums, val):
i=0
for j in range(len(nums)):
if nums[i]==val:
nums.pop(i)
else:
i+=1
return len(nums)

#### LeetCOde27详细分析并附求解代码

2017-01-16 19:45:18

#### 【leetcode c++】27 Remove Element

2015-06-22 00:48:04

#### (Java)LeetCode-27. Remove Element

2016-06-08 15:16:59

#### (java)leetcode-27

2017-04-06 21:57:48

#### leetcode27题 题解 翻译 C语言版 Python版

2016-04-15 09:43:08

#### leetcode 27. 移除元素 （python）

2018-05-31 00:33:10

#### leetcode 27 题解 翻译 Python版

2017-11-06 23:56:59

#### leetcode27——Remove Element

2018-04-12 16:20:30

#### LeetCode27——Remove Element

2015-02-11 15:20:33

#### LeetCode27:Remove Element

2015-05-29 23:50:00