JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

T442

发布时间 2023-03-23 22:01:15作者: 小趴菜且能喝66
class Solution {
    public List<Integer> findDuplicates(int[] nums) {
        List<Integer> x=new ArrayList<>();
        int[] flag=new int[nums.length+1];
        for(int i=0;i<nums.length+1;i++) {
            flag[i]=0;
        }
        for(int i=0;i<nums.length;i++) {
            if(nums[i]<=nums.length) {
                flag[nums[i]]++;
                if(flag[nums[i]]==2) {
                    x.add(nums[i]);
                }
            }
        }
        return x;

    }
}

 

    本栏目推荐文章
  • (坚持每天写算法)基础算法复习与学习part1基础算法1-7——高精度减法(处理t=1和t>1代码的写法,t为操作次数)
  • 2024-01-13 Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. ==》引用了未使用的方法导致
  • [linux kernel] struct pid && the way the kernel used to cast uint32_t pid to struct task_struct
  • C#中的List<T>和Dictionary<TKey, TValue>的底层原理
  • 【LeetCode 2989. 班级表现】T-SQL 动态sql编程示例
  • Virtualbox - VM can't start after OS update
  • 'gbk' codec can't decode byte 0xff in position 0
  • C# IEnumerable<T> 分批次返回
  • C# 接口IBufferWriter<T>学习理解
  • "mysql : 无法将“mysql”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。"错误以及"Can't connect to MySQL server on 'localhost' (10061) after Installation"错误解决办法
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们