Smallest Positive Missing
Lesson 16 of 26 in Coddy's Arrays in C++ course.
Challenge
Given an array of size n-1 consisting of different integers ranging from 1 to n (both inclusive), find the smallest positive number missing from the array.
For Example,
n=5;
Arr[]={1, 2, 4, 5};Here the smallest missing integer is 3.
Try it yourself
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int arr[n-1];
for(int i=0;i<n-1;i++){
cin>>arr[i];
}
//Write your code here
return 0;
}
All lessons in Arrays in C++
7Array Challenges
Reverse an ArraySmallest Positive MissingTranspose of MatrixAddition of Two MatrixMax and Min ElementCheck Palindrome2Memory Analysis
Memory Allocation