Algorithms—27.Remove Element
2015-06-02 16:41
381 查看
public class Solution {
public int removeElement(int[] nums, int val) {
int end=nums.length;
int k=0;
for (int i = 0; i < end; i++) {
if (nums[i]==val) {
for (int j = i; j < end-1; j++) {
k=nums[j];
nums[j]=nums[j+1];
nums[j+1]=k;
}
end--;
i--;
}
}
return end;
}
}
public int removeElement(int[] nums, int val) {
int end=nums.length;
int k=0;
for (int i = 0; i < end; i++) {
if (nums[i]==val) {
for (int j = i; j < end-1; j++) {
k=nums[j];
nums[j]=nums[j+1];
nums[j+1]=k;
}
end--;
i--;
}
}
return end;
}
}
相关文章推荐
- The Google File System
- Golang与C对比学习 (1)
- Google MapReduce
- Go语言Revel框架 环境搭建
- ubuntu安装Google Chrome浏览器
- windows下的go语言的环境搭建和初探
- GO语言学习-匿名函数和闭包
- Python win7下 django-admin.py startproject mysite命令没有创建mysite?
- poj 2007 Scrambled Polygon
- django模板使用
- Google NFC Basics (谷歌官网NFC翻译)
- Google Interview - Longest Continuous Path of Tree
- t-分布邻域嵌入算法(t-SNE algorithm)简单理解
- golang开源分布式文件系统weed-fs的安装与运用
- 用Go语言写了一个电脑搜索文件的小东西
- Algorithms—12.Integer to Roman
- Algorithms—13.Roman to Integer
- django用户验证模块核心
- pycharm 调试 django 应用
- leangoo更换背景、设置颜色标签功能上线啦!