<LeetCode><Easy> 27 Remove Elements
2015-10-17 14:21
288 查看
Given an array and a value, remove all instances of that value in place and return the new length.
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
#Python2 40ms
class Solution(object):
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
while 1:
try:
nums.pop(nums.index(val))
except:
return
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
#Python2 40ms
class Solution(object):
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
while 1:
try:
nums.pop(nums.index(val))
except:
return
相关文章推荐
- 命令行执行Java程序加载指定目录中的Jar文件
- 手机android端的html5页面用ajax访问服务器,后台成功从数据库查询到值,但是前段一直调用ajax的error
- Mixing two digital audio streams
- Swift 学习笔记(一)引用第三方库
- Tomcat配置
- 乘法器的延迟产生原因???
- 【IOS 开发学习总结-OC-51】★★★ios开发之UI控件——UITableView 与UITableViewCell
- 面试:百度,阿里等--10/2015
- python List 介绍
- S5PV210的kernel移植
- 动手动脑
- SecureCRT密钥登录
- 机器学习的常见面试问题
- easyui帮助文档地址
- 数据范围
- spring BeanDefinition
- JavaScript自定义回调函数
- IplImage, CvMat, Mat 的关系
- js中获取超链接参数里面的值
- 动态语言与静态语言的比较