LeetCode:Remove Element
2015-11-16 11:07
417 查看
Remove Element
Total Accepted: 85866 TotalSubmissions: 266809 Difficulty: Easy
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
Hide Tags
Array Two
Pointers
Hide Similar Problems
(E) Remove Linked List Elements (E)
Move Zeroes
code:
class Solution { public: int removeElement(vector<int>& nums, int val) { int cnt=0; for(int i=0;i<nums.size();i++) if(nums[i] != val) nums[cnt++] = nums[i]; return cnt; } };
相关文章推荐
- PyCharm 3的PEP8代码风格警告提示信息
- spring事务
- List
- cglib中Enhancer的简单使用
- Git笔记
- Sara小妹开始入门iOS开发
- 使用数组的内部指针next,end,reset,prev控制函数遍历数组
- Sharing code between unit tests and instrumentation tests on Android
- Java运算符
- c# 网站生成静态页面
- Windows下Android NDK开发的几种方法总结
- css(1)
- 设置powerdesigner的数据库类型
- BaiduMap
- poj1564-Sum It Up(经典DFS)
- ssl
- Java for Web学习笔记(八):Servlet(6)doGet()和doPost()是线程还是队列
- NOIP2015复赛题解报告答案以及代码
- 【详解】后台修改---增加新模块功能
- 正手中远台攻球