#-*- coding: UTF-8 -*-
class Solution(object):
    def removeElement(self, nums, val):
        """
        :type nums: List[int]
        :type val: int
        :rtype: int
        """
        for i in range(len(nums)-1,-1,-1):
            if nums[i]==val:
                del nums[i]
        
        return len(nums)
    
sol=Solution()
print sol.removeElement([3,2,2,3], 3)

【leetcode❤python】27. Remove Element的更多相关文章

  1. 【leetcode❤python】169. Majority Element

    #Method 1import math class Solution(object):    def majorityElement(self, nums):        numsDic={}   ...

  2. [LeetCode&Python] Problem 27. Remove Element

    Given an array nums and a value val, remove all instances of that value in-placeand return the new l ...

  3. 【leetcode❤python】 203. Remove Linked List Elements

    #-*- coding: UTF-8 -*- # Definition for singly-linked list.# class ListNode(object):#     def __init ...

  4. 【leetcode❤python】 19. Remove Nth Node From End of List

    #-*- coding: UTF-8 -*-#双指针思想,两个指针相隔n-1,每次两个指针向后一步,当后面一个指针没有后继了,前面一个指针的后继就是要删除的节点# Definition for sin ...

  5. 【leetcode❤python】83. Remove Duplicates from Sorted List

    #-*- coding: UTF-8 -*- # Definition for singly-linked list.# class ListNode(object):#     def __init ...

  6. 【leetcode❤python】26. Remove Duplicates from Sorted Array

    #-*- coding: UTF-8 -*-class Solution(object):    def removeDuplicates(self, nums):        "&quo ...

  7. leetCode练题——27. Remove Element

    1.题目 27. Remove Element——Easy Given an array nums and a value val, remove all instances of that valu ...

  8. 【LeetCode】27. Remove Element (2 solutions)

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

  9. 【leetcode❤python】Sum Of Two Number

    #-*- coding: UTF-8 -*- #既然不能使用加法和减法,那么就用位操作.下面以计算5+4的例子说明如何用位操作实现加法:#1. 用二进制表示两个加数,a=5=0101,b=4=0100 ...

随机推荐

  1. angular Creating a Directive that Adds Event Listeners

    <span my-draggable>Drag ME</span> angular.module('dragModule', []) .directive('myDraggab ...

  2. WMI技术介绍和应用——查询硬件信息

    //查询得到系统盘所在硬盘的ID SELECT DiskIndex FROM Win32_DiskPartition WHERE Bootable = TRUE //如何使用WMI查询系统盘所在硬盘的 ...

  3. 导出excel部分代码

    public static function header_file($doc,$file,$title,$type='Excel5'){ if(!empty($doc)){ $objWriter = ...

  4. Android多线程通信之Handler

    主线程 public class MainActivity extends ActionBarActivity { private Handler handler; // private Thread ...

  5. WCF入门教程:WCF基础知识问与答(转)

    学习WCF已有近两年的时间,其间又翻译了Juval的大作<Programming WCF Services>,我仍然觉得WCF还有更多的内容值得探索与挖掘.学得越多,反而越发觉得自己所知太 ...

  6. asp显示记录条数

    Sql = "select * from xin126 where ID=" & id Rs.Open Sql,Conn,1,1 %> 共有<strong st ...

  7. SpringMVC整合TaskExecutor线程池的配置/使用

    一.配置jdbc.properties添加: #------------ Task ------------ task.core_pool_size=5 task.max_pool_size=50 t ...

  8. Content Delivery Network

    Coding Standards & Best Practices 7 Reasons to use a Content Delivery Network CDN公共库汇总

  9. bodybuilding

    增大肌肉块的14大秘诀:大重量.低次数.多组数.长位移.慢速度.高密度.念动一致.顶峰收缩.持续紧张.组间放松.多练大肌群.训练后进食蛋白质.休息48小时.宁轻勿假. 1. 大重量.低次数:健美理论中 ...

  10. sqlite3把字段为int32(用c++的time(nullptr)获取的)的秒数显示为年月日时分秒

    select id, type, msg, datetime(updateTime, 'unixepoch', 'localtime') from ServerLog