首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
不在数组里的最小正整数
[编程题]不在数组里的最小正整数
热度指数:12432
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32M,其他语言64M
算法知识视频讲解
给出一个无序的整数型数组,求不在给定数组里的最小的正整数
例如:
给出的数组为
[1,2,0] 返回3,
给出的数组为
[4,3,-1,-2,1] 返回2.
你需要给出时间复杂度在O(n)之内并且空间复杂度为常数级的算法
示例1
输入
[1,2,0]
输出
3
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(7)
邀请回答
收藏(79)
分享
提交结果有问题?
44个回答
1篇题解
开通博客
诗云panther
发表于 2021-08-20 12:28:19
class Solution {public: /* * * @param A int整型一维数组 * @param n int A数组长度 * @return int整型 */ int firstMissingPositive(int A, in
展开全文
问题信息
数组
难度:
44条回答
79收藏
19720浏览
热门推荐
通过挑战的用户
查看代码
夏天丶
2022-11-28 12:51:13
牛客89690...
2022-10-18 22:56:28
ԅ(¯ㅂ¯ԅ)...
2022-10-18 20:07:51
牛爱网一号男嘉宾
2022-10-13 20:04:33
liulx15
2022-09-27 14:27:17
相关试题
设某二叉树的先序遍历序列为abdg...
树
评论
(1)
游戏内数据分析涉猎的少,如何证明自...
评论
(1)
之前的经历中单品数据分析的经验丰富...
评论
(1)
什么样的人适合做数据分析
评论
(1)
2022 诺瓦科技 Perl re...
perl
System Verilog
评论
(1)
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * * @param A int整型一维数组 * @return int整型 */ public int firstMissingPositive (int[] A) { // write code here } }
class Solution { public: /** * * @param A int整型一维数组 * @param n int A数组长度 * @return int整型 */ int firstMissingPositive(int* A, int n) { // write code here } };
# # # @param A int整型一维数组 # @return int整型 # class Solution: def firstMissingPositive(self , A ): # write code here
/** * * @param A int整型一维数组 * @return int整型 */ function firstMissingPositive( A ) { // write code here } module.exports = { firstMissingPositive : firstMissingPositive };
# # # @param A int整型一维数组 # @return int整型 # class Solution: def firstMissingPositive(self , A ): # write code here
package main /** * * @param A int整型一维数组 * @return int整型 */ func firstMissingPositive( A []int ) int { // write code here }
[1,2,0]
3