首页
题库
面试
求职
课程
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
区间列表交集
[编程题]区间列表交集
热度指数:352
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
给定两个由闭区间组成的列表 first 和 second ,其中
,
表示区间,保证这两个列表内部是不存在交集的,并且是排序之后的。
请找出两个区间列表的交集。
数据范围:区间列表的长度满足
, 区间列表中的值满足
示例1
输入
[[0,2],[5,10],[11,13]],[[1,3],[5,11]]
输出
[[1,2],[5,10],[11,11]]
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(15)
分享
纠错
提交结果有问题?
5个回答
1篇题解
开通博客
God-father姜
发表于 2023-02-23 22:06:26
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param first int整型二维数组 # @param second int整型二维数组 # @return(756076230) int整型二维数组 # class Solution:
展开全文
问题信息
双指针
难度:
5条回答
15收藏
1001浏览
热门推荐
通过挑战的用户
查看代码
牛客11870...
2022-09-15 16:00:53
tzj+
2022-09-09 16:45:00
林子20190...
2022-09-06 13:11:30
牛客85940...
2022-09-03 15:38:47
_天之白_
2022-09-01 23:20:28
相关试题
和为S的两个数字
数组
数学
双指针
评论
(1508)
来自
“一战通offer”互联...
神奇的数字
排序
双指针
评论
(46)
最小面积子矩阵
动态规划
双指针
前缀和
评论
(44)
在IP地址方案中,159.226....
网络基础
评论
(1)
使用全局置换算法,程序不可控制自身...
操作系统
评论
(1)
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param first int整型ArrayList
> * @param second int整型ArrayList
> * @return int整型ArrayList
> */ public ArrayList
> intersectionofintervals (ArrayList
> first, ArrayList
> second) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param first int整型vector
> * @param second int整型vector
> * @return int整型vector
> */ vector
> intersectionofintervals(vector
>& first, vector
>& second) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param first int整型二维数组 # @param second int整型二维数组 # @return int整型二维数组 # class Solution: def intersectionofintervals(self , first , second ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param first int整型二维数组 * @param second int整型二维数组 * @return int整型二维数组 */ public List
> intersectionofintervals (List
> first, List
> second) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param first int整型二维数组 * @param second int整型二维数组 * @return int整型二维数组 */ function intersectionofintervals( first , second ) { // write code here } module.exports = { intersectionofintervals : intersectionofintervals };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param first int整型二维数组 # @param second int整型二维数组 # @return int整型二维数组 # class Solution: def intersectionofintervals(self , first: List[List[int]], second: List[List[int]]) -> List[List[int]]: # write code here
package main //import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param first int整型二维数组 * @param second int整型二维数组 * @return int整型二维数组 */ func intersectionofintervals( first [][]int , second [][]int ) [][]int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param first int整型二维数组 * @param firstRowLen int first数组行数 * @param firstColLen int* first数组列数 * @param second int整型二维数组 * @param secondRowLen int second数组行数 * @param secondColLen int* second数组列数 * @return int整型二维数组 * @return int* returnSize 返回数组行数 * @return int** returnColumnSizes 返回数组列数 */ int** intersectionofintervals(int** first, int firstRowLen, int* firstColLen, int** second, int secondRowLen, int* secondColLen, int* returnSize, int** returnColumnSizes ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param first int整型二维数组 # @param second int整型二维数组 # @return int整型二维数组 # class Solution def intersectionofintervals(first, second) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param first int整型二维数组 * @param second int整型二维数组 * @return int整型二维数组 */ def intersectionofintervals(first: Array[Array[Int]],second: Array[Array[Int]]): Array[Array[Int]] = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param first int整型二维数组 * @param second int整型二维数组 * @return int整型二维数组 */ fun intersectionofintervals(first: Array
,second: Array
): Array
{ // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param first int整型二维数组 * @param second int整型二维数组 * @return int整型二维数组 */ public int[][] intersectionofintervals (int[][] first, int[][] second) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param first int整型二维数组 * @param second int整型二维数组 * @return int整型二维数组 */ export function intersectionofintervals(first: number[][], second: number[][]): number[][] { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param first int整型二维数组 * @param second int整型二维数组 * @return int整型二维数组 */ func intersectionofintervals ( _ first: [[Int]], _ second: [[Int]]) -> [[Int]] { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param first int整型二维数组 * @param second int整型二维数组 * @return int整型二维数组 */ pub fn intersectionofintervals(&self, first: Vec
>, second: Vec
>) -> Vec
> { // write code here } }
[[0,2],[5,10],[11,13]],[[1,3],[5,11]]
[[1,2],[5,10],[11,11]]