【LeetCode 26】删除排序数组中的重复项
2024-10-07 18:38:24
【题解】
沙比提
【代码】
class Solution {
public:
int removeDuplicates(vector<int>& nums) {
if (nums.empty()) return 0;
int idx = 0;
int len = nums.size();
for (int i = 1;i < len;i++)
if (nums[i]!=nums[i-1]){
nums[++idx] = nums[i];
}
return idx+1;
}
};
最新文章
- 64位下pwntools中dynELF函数的使用
- Linq 单表城市级联
- 根据 MySQL 状态优化 ---- 4. 临时表
- selenium support
- Python基础4:数据类型:数字 字符串 日期
- 基于zepto判断mobile的横竖屏状态
- Bootstrap的clearfix
- vim MiniBufExplorer 插件
- 使用WeCloud消息推送接口发送消息NodeJs版
- 用PetaPoco为ASP.NET已有数据库建模
- [jzoj]3456.【NOIP2013模拟联考3】恭介的法则(rule)
- springboot学习一:快速搭建springboot项目
- struts2框架学习之第一天
- ZC_C++类函数指针_模拟_Delphi类函数指针
- VirtualBox 快捷键
- 解决securecrt连接centos使用VIM编辑中文时乱码
- 2014-2015 ACM-ICPC, NEERC, Eastern Subregional Contest Problem G. The Debut Album
- LightOJ - 1297 Largest Box LightOJ(一元三次方程求极大值)
- RabbitMQ 命令
- 【转】hexo博客图片问题