首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
最长的连续元素序列长度
[编程题]最长的连续元素序列长度
热度指数:29575
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32M,其他语言64M
算法知识视频讲解
给定一个无序的整数类型数组,求最长的连续
元素
序列的长度。
例如:
给出的数组为
[1000, 4, 2000, 1, 3, 2],
最长的连续
元素
序列
为
[1, 2, 3, 4].
返回这个序列的长度:4
你需要给出
时间
复杂度在O(n)之内的算法
示例1
输入
[1000, 4, 2000, 1, 3, 2]
输出
4
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(16)
邀请回答
收藏(175)
分享
提交结果有问题?
0个回答
5篇题解
添加回答
这道题你会答吗?花几分钟告诉大家答案吧!
提交观点
问题信息
数组
查找
难度:
0条回答
175收藏
36565浏览
热门推荐
通过挑战的用户
查看代码
牛客38959...
2023-02-15 15:30:38
开心的孤勇者在抱佛脚
2023-02-14 10:32:50
牛客38441...
2022-09-13 16:23:41
牛客61312...
2022-09-10 23:41:54
牛客72674...
2022-09-09 15:32:57
相关试题
防火墙是怎么实现的?
计算机网络基础
评论
(1)
PMOS和NMOS的区别
元器件
评论
(1)
“乔布斯不做调查,张小龙不看数据。...
用户研究
评论
(1)
相关性分析有哪些?
评论
(1)
如何检验聚类分析结果
评论
(1)
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * * @param num int整型一维数组 * @return int整型 */ public int longestConsecutive (int[] num) { // write code here } }
class Solution { public: /** * * @param num int整型vector * @return int整型 */ int longestConsecutive(vector
& num) { // write code here } };
# # # @param num int整型一维数组 # @return int整型 # class Solution: def longestConsecutive(self , num ): # write code here
/** * * @param num int整型一维数组 * @return int整型 */ function longestConsecutive( num ) { // write code here } module.exports = { longestConsecutive : longestConsecutive };
# # # @param num int整型一维数组 # @return int整型 # class Solution: def longestConsecutive(self , num ): # write code here
package main /** * * @param num int整型一维数组 * @return int整型 */ func longestConsecutive( num []int ) int { // write code here }
[1000, 4, 2000, 1, 3, 2]
4