# 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]Distinct Subsequences

Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequen...

## LeetCode_27---Remove Element

Given an array and a value, remove all instances of that value in place and return the new length. ...

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

27. Remove Element Given an array and a value, remove all instances of that value in place and ...

## Leetcode - Array - 27. Remove Element（第一道题）

1.Problem description Given an array and a value, remove all instances of that value in place and re...

## leetcode题解-26. Remove Duplicates from Sorted Array && 27. Remove Element

Remove Duplicates from Sorted Array，题目：Given a sorted array, remove the duplicates in place such tha...

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)