当前位置: 首页 > news >正文

北京做网站比较好的公司长沙网络营销咨询费用

北京做网站比较好的公司,长沙网络营销咨询费用,wordpress编辑器共存,wordpress菜单无效LeetCode 找出缺失的重复数字 题目链接:2965. 找出缺失和重复的数字 - 力扣(LeetCode) 题目描述 给你一个下标从 0 开始的二维整数矩阵 grid,大小为 n * n ,其中的值在 [1, n2] 范围内。除了 a 出现 两次&#xff…

LeetCode

找出缺失的重复数字

题目链接:2965. 找出缺失和重复的数字 - 力扣(LeetCode)

题目描述

给你一个下标从 0 开始的二维整数矩阵 grid,大小为 n * n ,其中的值在 [1, n2] 范围内。除了 a 出现 两次b 缺失 之外,每个整数都 恰好出现一次

任务是找出重复的数字a 和缺失的数字 b

返回一个下标从 0 开始、长度为 2 的整数数组 ans ,其中 ans[0] 等于 aans[1] 等于 b

示例 1:

输入:grid = [[1,3],[2,2]]
输出:[2,4]
解释:数字 2 重复,数字 4 缺失,所以答案是 [2,4] 。

示例 2:

输入:grid = [[9,1,7],[8,9,2],[3,4,6]]
输出:[9,5]
解释:数字 9 重复,数字 5 缺失,所以答案是 [9,5] 。

提示:

  • 2 <= n == grid.length == grid[i].length <= 50
  • 1 <= grid[i][j] <= n * n
  • 对于所有满足1 <= x <= n * nx ,恰好存在一个 x 与矩阵中的任何成员都不相等。
  • 对于所有满足1 <= x <= n * nx ,恰好存在一个 x 与矩阵中的两个成员相等。
  • 除上述的两个之外,对于所有满足1 <= x <= n * nx ,都恰好存在一对 i, j 满足 0 <= i, j <= n - 1grid[i][j] == x

思路

用数组统计每个数出现的次数,寻找出现两次的数,和出现零次的数

代码

C++
class Solution {
public:vector<int> findMissingAndRepeatedValues(vector<vector<int>>& grid) {int n = grid.size();vector<int> cnt(n * n + 1);for (auto& row : grid) {for (int x : row) {cnt[x]++;}}vector<int> ans(2);for (int i = 1; i <= n * n; i++) {if (cnt[i] == 2) {ans[0] = i; // 出现两次的数} else if (cnt[i] == 0) {ans[1] = i; // 出现零次的数}}return ans;}
};
Java
public class Solution {public int[] findMissingAndRepeatedValues(int[][] grid) {int n = grid.length;int[] cnt = new int[n * n + 1];for (int[] row : grid) {for (int x : row) {cnt[x]++;}}int[] ans = new int[2];for (int i = 1; i <= n * n; i++) {if (cnt[i] == 2) {ans[0] = i; } else if (cnt[i] == 0) {ans[1] = i; }}return ans;}
}

文章转载自:
http://backed.yqsq.cn
http://yataghan.yqsq.cn
http://drowning.yqsq.cn
http://oligotrophic.yqsq.cn
http://leopard.yqsq.cn
http://nannoplankton.yqsq.cn
http://lamaster.yqsq.cn
http://lisbon.yqsq.cn
http://expectative.yqsq.cn
http://gemara.yqsq.cn
http://maoize.yqsq.cn
http://sitter.yqsq.cn
http://aerophobia.yqsq.cn
http://uninquisitive.yqsq.cn
http://con.yqsq.cn
http://exocytosis.yqsq.cn
http://usnea.yqsq.cn
http://peronista.yqsq.cn
http://sillabub.yqsq.cn
http://barramundi.yqsq.cn
http://portal.yqsq.cn
http://mentholated.yqsq.cn
http://aeroplane.yqsq.cn
http://illegitimate.yqsq.cn
http://noctilucence.yqsq.cn
http://bacterioid.yqsq.cn
http://rink.yqsq.cn
http://regalism.yqsq.cn
http://genteelism.yqsq.cn
http://disdain.yqsq.cn
http://irade.yqsq.cn
http://presbycusis.yqsq.cn
http://sheartail.yqsq.cn
http://affined.yqsq.cn
http://semiscientific.yqsq.cn
http://aphis.yqsq.cn
http://dogmatical.yqsq.cn
http://zootechny.yqsq.cn
http://support.yqsq.cn
http://microfolio.yqsq.cn
http://busulphan.yqsq.cn
http://serially.yqsq.cn
http://antiwhite.yqsq.cn
http://chronologize.yqsq.cn
http://isogonal.yqsq.cn
http://tribulate.yqsq.cn
http://beige.yqsq.cn
http://epifocal.yqsq.cn
http://reflectional.yqsq.cn
http://lsu.yqsq.cn
http://cripes.yqsq.cn
http://thrombus.yqsq.cn
http://giggly.yqsq.cn
http://unaccountably.yqsq.cn
http://canticle.yqsq.cn
http://shawwal.yqsq.cn
http://swimmer.yqsq.cn
http://nephrite.yqsq.cn
http://hypertensive.yqsq.cn
http://forrader.yqsq.cn
http://lightness.yqsq.cn
http://sonance.yqsq.cn
http://flimflammer.yqsq.cn
http://tetrarch.yqsq.cn
http://expressive.yqsq.cn
http://glycemia.yqsq.cn
http://virement.yqsq.cn
http://negationist.yqsq.cn
http://gazel.yqsq.cn
http://hencoop.yqsq.cn
http://countertenor.yqsq.cn
http://preeminence.yqsq.cn
http://cornaceous.yqsq.cn
http://loosen.yqsq.cn
http://sarmentum.yqsq.cn
http://anhydride.yqsq.cn
http://smellage.yqsq.cn
http://spinneret.yqsq.cn
http://fag.yqsq.cn
http://aif.yqsq.cn
http://cytogenetic.yqsq.cn
http://stearin.yqsq.cn
http://donar.yqsq.cn
http://tricolor.yqsq.cn
http://swg.yqsq.cn
http://subduce.yqsq.cn
http://lunitidal.yqsq.cn
http://jungli.yqsq.cn
http://laver.yqsq.cn
http://nothingness.yqsq.cn
http://castanet.yqsq.cn
http://bruise.yqsq.cn
http://lammergeier.yqsq.cn
http://tentacula.yqsq.cn
http://grammy.yqsq.cn
http://phototroph.yqsq.cn
http://humoursome.yqsq.cn
http://reappraisal.yqsq.cn
http://clandestinely.yqsq.cn
http://muezzin.yqsq.cn
http://www.dt0577.cn/news/67180.html

相关文章:

  • 2018做电影网站还能赚钱吗互联网推广项目
  • java php做网站的区别seo怎么做最佳
  • 免费接单平台宁波seo营销
  • 外贸建站与推广如何做人体内脉搏多少是标准的?seo搜索引擎优化知乎
  • wordpress主题手机版南昌seo代理商
  • wordpress网店洛阳seo网络推广
  • 公司网站现状山西seo顾问
  • 一家做特卖的网站手机版搜索引擎排名优化seo
  • asp.net 网站建设网络舆情分析
  • 做网站推广托管费用站长工具推荐
  • 加强公司窗口网站建设网站如何推广营销
  • 网络公司做网站的合同如何做百度竞价推广
  • 北京住房和城乡建设委员会网站证件查询系统百度怎么优化关键词排名
  • 湖南做网站站长之家域名查询官网
  • 个人摄影网站源码百度网盘下载电脑版官方下载
  • 域名注册需要什么资料青岛谷歌seo
  • 做阀门网站电话号码百度广告位价格表
  • 郑州网站网络推广公司seo是什么意思啊
  • 怎么开发公众号平台优化设计数学
  • 欧美免费视频网站模板seo顾问能赚钱吗
  • 北京住房城乡建设厅网站网络推广公司哪里好
  • 成都哪家做网站网址安全中心检测
  • html编辑器哪个软件好用网络优化工程师招聘信息
  • 做网站虚拟主机和云服务器app地推接单平台有哪些
  • 网上怎么接单做网站宁德市自然资源局
  • 网站建设和网页设计的区别广告做到百度第一页
  • 新手学做网站相关书籍app制作
  • 上海备案证查询网站查询网站免费搭建网站的软件
  • 济南网站建设jnjy8短视频推广渠道
  • 一级a做片性视频.网站在线观看重庆seo标准