problem

448. Find All Numbers Disappeared in an Array

solution:

class Solution {
public:
vector<int> findDisappearedNumbers(vector<int>& nums) {
vector<int> res;
for(int i=; i<nums.size(); i++)
{
int tmp = abs(nums[i]) - ;
nums[tmp] = nums[tmp]> ? -nums[tmp] : nums[tmp];
}
for(int i=; i<nums.size(); i++)
{
if(nums[i]>) res.push_back(i+);
}
return res;
}
};

参考

1. Leetcode_448. Find All Numbers Disappeared in an Array;

2. GrandYang;

【leetcode】448. Find All Numbers Disappeared in an Array的更多相关文章

  1. 【LeetCode】448. Find All Numbers Disappeared in an Array 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 方法一:暴力求解 方法二:原地变负做标记 方法三:使用set ...

  2. [leetcode]python 448. Find All Numbers Disappeared in an Array

    Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and ot ...

  3. 448. Find All Numbers Disappeared in an Array【easy】

    448. Find All Numbers Disappeared in an Array[easy] Given an array of integers where 1 ≤ a[i] ≤ n (n ...

  4. 【LeetCode】165. Compare Version Numbers 解题报告(Python)

    [LeetCode]165. Compare Version Numbers 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博 ...

  5. leetcode 217. Contains Duplicate 287. Find the Duplicate Number 442. Find All Duplicates in an Array 448. Find All Numbers Disappeared in an Array

    后面3个题都是限制在1-n的,所有可以不先排序,可以利用巧方法做.最后两个题几乎一模一样. 217. Contains Duplicate class Solution { public: bool ...

  6. 448. Find All Numbers Disappeared in an Array&&645. Set Mismatch

    题目: 448. Find All Numbers Disappeared in an Array Given an array of integers where 1 ≤ a[i] ≤ n (n = ...

  7. 448. Find All Numbers Disappeared in an Array@python

    Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and ot ...

  8. LeetCode算法题-Find All Numbers Disappeared in an Array(Java实现)

    这是悦乐书的第232次更新,第245篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第99题(顺位题号是448).给定一个整数数组,其中1≤a[i]≤n(n =数组的大小) ...

  9. 【LeetCode】445. Add Two Numbers II 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 先求和再构成列表 使用栈保存节点数字 类似题目 日期 ...

随机推荐

  1. mongodb主从(副本集附仲裁节点)部署带认证模式

    环境:OS:CentOS 7DB:3.0.15机器角色:192.168.1.134:10001 主192.168.1.135:10002 从192.168.1.135:10003 仲裁节点 1.下载相 ...

  2. ldap 集成harbor

    harbor: 1.6 默认配置文件在harbor.cfg,我们可以先不添加配置,直接在harbor web界面进行配置(harbor 1.6 如果db 启动失败提示postgresql 数据目录已存 ...

  3. redis 序列化存入对象

    redis 序列化存入对象 //序列化 public static byte [] serialize(Object obj){ ObjectOutputStream obi=null; ByteAr ...

  4. ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet………

    在照着这里例子学习ssm时,在部署阶段遇到了这个问题“ASM ClassReader failed to parse class file - probably due to a new Java c ...

  5. map的循环删除操作

    1.错误示例 Map<String,InterfaceOutParam> outCodes1 = outParamList.stream().collect(Collectors.toMa ...

  6. vue-update-表单形式复写方法上传图片

    handleSave() { const formData = new FormData(); /* eslint-disable */ for (let key in this.dataInfo) ...

  7. kibana升级之后原本保存的数据dashboards, visualizations, index patterns丢失

    1,es升级注意的问题:https://www.elastic.co/guide/en/elasticsearch/reference/6.5/rolling-upgrades.html 2,kiba ...

  8. laravel 路由的配置

  9. 图论++【洛谷p1744】特价采购商品&&【一本通1342】最短路径问题

    (虽然题面不是很一样,但是其实是一个题qwq) [传送门] 算法标签: 利用Floyed的o(n3)算法: (讲白了就是暴算qwq) 从任意一条单边路径开始.所有两点之间的距离是边的权,或者无穷大,如 ...

  10. 洛谷P3225 HNOI2012 矿场搭建

    题目描述 煤矿工地可以看成是由隧道连接挖煤点组成的无向图.为安全起见,希望在工地发生事故时所有挖煤点的工人都能有一条出路逃到救援出口处.于是矿主决定在某些挖煤点设立救援出口,使得无论哪一个挖煤点坍塌之 ...