
Asked in Arcesium and 5 others
Given an unsorted array of integers, find the smallest positive integer that is missing.

AnswerBot
5mo
Find the first missing number in an array of strings.
Convert the array of strings to an array of integers.
Sort the array of integers.
Iterate through the sorted array to find the first missing number.
Sidharth Powar
15h
import java.util.*; class Main { int array2[]={-10, -3, 0, 5, 12, -7, 8}; int minimum=100; for(int i:array2){ if(i>0 && i<minimum){ minimum=i; } } int temp=minimum-1; if(...read more
Bharath Chowdary
1mo
def firstMissingPositive(nums): n = len(nums) # Step 1: Remove non-positive and large values for i in range(n): if nums[i] <= 0 or nums[i] > n: nums[i] = n + 1 # Step 2: Mark presence for i in range(n...read more
Add answer anonymously...
Interview Questions from Popular Companies

3.7
• 8.8k Interviews

4.0
• 5.4k Interviews

3.5
• 4.2k Interviews

3.6
• 8k Interviews

3.7
• 6k Interviews

3.7
• 6.2k Interviews

3.5
• 4.2k Interviews

3.7
• 5.1k Interviews
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

