Leetcode #27 Remove Element

原创 2015年07月08日 21:28:01

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.

Difficulty : Easy

很简单。。不多说了。

int removeElement(vector<int>& nums, int val) {
    int len = nums.size();
    int cou = 0;
        for(int i =0; i<len;i++){
            if(nums[i]==val){
              nums[i]=2147483647;
              cou++;
            }
        }
        sort(nums.begin(),nums.end()); 
        return len - cou;
    }


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Leetcode_27_Remove Element

本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/41577997 Remove Element Given ...

LeetCode_27---Remove Element

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

LeetCode笔记:27. Remove Element

固定内存下移除数组中特定的数字

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 27_Remove Element

这个题亦不是很难,并没有太多可说的,我们尽快结果了它吧。 题目也是要从数组中移除元素的,但算法还是有点儿小差别的,算是两个不同的小技巧吧。看题 Given an array and a v...
  • cyfcsd
  • cyfcsd
  • 2015年11月25日 15:54
  • 232

LeetCode(27)Remove Element

题目如下 Given an array and a value, remove all instances of that value in place and return the new leng...

[leetcode]27.Remove Element(Java)

测试地址:https://leetcode.com/problems/remove-element/#/description Given an array and ...

leetcode 27. Remove Element

题目描述: Given an array and a value, remove all instances of that value in place and return the new l...

【leetcode c++】27 Remove Element

Remove Element Given an array and a value, remove allinstances of that value in place and return th...
  • hqq39
  • hqq39
  • 2015年06月22日 00:48
  • 342

leetcode 27 Remove Element

27. Remove Element Given an array and a value, remove all instances of that value in place and ret...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Leetcode #27 Remove Element
举报原因:
原因补充:

(最多只允许输入30个字)