#include <bits/stdc++.h> bool search(int arr[],int n,int num) { for(int i=0 ; i<=n ; i++) { if(arr[i]==num) return true; } return false; } int firstMissing(int arr[], int n) { for(int i=1 ; i<=n ; i++) { if(search(arr,n,i)==false) return i; } return n+1; } time complexity-O(N2)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter