博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
leetcode 27. [Array]Remove Element
阅读量:4221 次
发布时间:2019-05-26

本文共 539 字,大约阅读时间需要 1 分钟。

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.

Subscribe to see which companies asked this question

class Solution(object):    def removeElement(self, nums, val):        j=0;count=0        for i in range(len(nums)):            if nums[i]!=val:                nums[j]=nums[i]                j=j+1            else:                count=count+1        for i in range(count):            nums.pop()

转载地址:http://uzqmi.baihongyu.com/

你可能感兴趣的文章
对CODEFISH的意见
查看>>
新的构架
查看>>
微软真强啊!这么恶心的model(转自msdn)-----front controller
查看>>
10个月以后 重新开启我的Blog
查看>>
认输了
查看>>
学校的日子
查看>>
我的项目,我的起点
查看>>
决定不逃课了~~~
查看>>
遇到技术问题~~
查看>>
终于弄懂了聊天室的各种技术了
查看>>
母函数算法---组合数学
查看>>
分手快乐---(哪个更好呢)
查看>>
要考试--大敌当前
查看>>
linux 编译技术 6级强化
查看>>
扩大工作室?
查看>>
拜读ms的开源代码
查看>>
下一个技术瓶颈 ~~
查看>>
谢谢让我看到了这本书
查看>>
不牵手的浪漫
查看>>
姥姥的生日~~
查看>>