Remove Element
来源:互联网 发布:python递归算法 编辑:程序博客网 时间:2024/05/01 21:45
Remove Element
Total Accepted: 8010 Total Submissions: 24406My SubmissionsGiven 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.
class Solution {public: int removeElement(int A[], int n, int elem) { int i=0,j=0; int len = n; while (i<n) { if (elem == A[i]){ ++i; len--; } else { A[j++]=A[i++]; } } return len; }};
0 0
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- Remove Element
- 在Eclipse里使用JSHint 检查 js代码
- 【.NET线程--进阶(二)】--小问题?不简单……
- MyEclipse8.5中改变默认空间workspace
- 关于struts2中action请求会执行两次的问题
- 王垠:程序员的心理疾病
- Remove Element
- Highcharts数据注意事项
- 拓胜第五十九天
- loadView和viewDidLoad的官方API的一些解释
- 开放ubuntu server的指定端口
- jenkins在自动化测试中的应用(Selenium+Python+Jenkins)
- 新的一年,新的希望,新的努力
- 练习,贪财的富翁
- 【Objective-C】OC中键值编码(KVC)的概念和使用方法