From 95465b026216ae19a948d16e1f65a0aec164d0e5 Mon Sep 17 00:00:00 2001 From: Atig Chkb <64916381+atig05@users.noreply.github.com> Date: Mon, 3 Oct 2022 21:40:30 +0530 Subject: [PATCH] Add files via upload Given an unsorted integer array nums, return the smallest missing positive integer. You must implement an algorithm that runs in O(n) time and uses constant extra space. Example 1: Input: nums = [1,2,0] Output: 3 Explanation: The numbers in the range [1,2] are all in the array. --- First Missing Positive leetcode.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 First Missing Positive leetcode.cpp diff --git a/First Missing Positive leetcode.cpp b/First Missing Positive leetcode.cpp new file mode 100644 index 0000000..18383b5 --- /dev/null +++ b/First Missing Positive leetcode.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; +int firstMissingPositive(vector& nums) { + unordered_map mp; + for(int i=0;i>n + vector nums(n,0); + for(int i=0;i>nums[i]; + cout<