首页 > 滚动

LeetCode 2661. First Completely Painted Row or Column 每日观察

互联网 2023-06-22 13:37:47

You are given a 0-indexed integer array arr, and an m x ninteger matrix matarrand matboth contain all the integers in the range [1, m * n].

Go through each index iin arrstarting from index 0and paint the cell in matcontaining the integer arr[i].


(相关资料图)

Return the smallest index iat which either a row or a column will be completely painted in mat.

Example 1:

Input: arr = [1,3,4,2], mat = [[1,4],[2,3]]

Output: 2

Explanation: The moves are shown in order, and both the first row and second column of the matrix become fully painted at arr[2].

Example 2:

Input: arr = [2,8,7,4,1,3,5,6,9], mat = [[3,2,5],[1,4,6],[8,7,9]]

Output: 3

Explanation: The second column becomes fully painted at arr[3].

Constraints:

m == mat.length

n = mat[i].length

arr.length == m * n

1 <= m, n <= 105

1 <= m * n <= 105

1 <= arr[i], mat[r][c] <= m * n

All the integers of arrare unique.

All the integers of matare unique.

中文翻译:

给你一个下标从 0 开始的整数数组 arr 和一个 m x n 的整数 矩阵 mat 。arr 和 mat 都包含范围 [1,m * n] 内的 所有 整数。

从下标 0 开始遍历 arr 中的每个下标 i ,并将包含整数 arr[i] 的 mat 单元格涂色。

请你找出 arr 中在 mat 的某一行或某一列上都被涂色且下标最小的元素,并返回其下标 i 。

多用hash;

下面是代码:

Runtime: 90 ms, faster than 11.53% of Java online submissions for First Completely Painted Row or Column.

Memory Usage: 80.3 MB, less than 7.42% of Java online submissions for First Completely Painted Row or Column.

上一篇 下一篇
热文推荐 更多

LeetCode 2661. First Completely Painted Row or Column 每日观察

2023-06-22

快资讯:端午安康 | 古诗词里话消防

2023-06-22

今日聚焦!兰州高新区 引大引强引头部 打造区域创新策源地

2023-06-22

水泥稳定土

2023-06-22

【新要闻】超150亿元市值蒸发!

2023-06-22

全球石油需求结构加速调整 快看点

2023-06-22

boy next door♂_boy next door

2023-06-22

中方代表在联合国人权理事会就涉疆等问题阐明严正立场

2023-06-22

准大学生千万别买 Macbook 了!大学里苹果电脑没比板砖强多少! 世界聚焦

2023-06-22

浏览器弹出窗口拦截功能怎么关闭360-浏览器弹出窗口拦截功能怎么关闭

2023-06-22

房山居民今天有一堆好消息!涉及交通、教育、医疗——-天天要闻

2023-06-22

宝宝方颅图片_方颅和额头高的区别

2023-06-22

润建股份:五象云谷云计算中心已安装2000个机架 并正式开始运营

2023-06-21

保罗谈19火箭:阿里扎被放走 有高管认为数据一样就可替换球员|世界要闻

2023-06-21

重点聚焦!曝追梦将续约勇士!名嘴直言他绝配1亿:邓利维5亿支出跑不掉?

2023-06-21

前台接待表扬信-天天报道

2023-06-21

人民币兑美元突破7.20大关,或将利好出口!

2023-06-21

每日看点!今年前5月上海累计离境退税销售额3.5亿元

2023-06-21

【世界独家】令我郁闷的工业糖

2023-06-21

快报:常德开展节令食品包装“瘦身”行动 集中整治商品过度包装

2023-06-21