### Find missing number between 1 to 100 in unsortedArray - in one iteration in java

In this core java programming tutorial we will write a program to Find missing number between 1 to 100 in unSortedArray in one iteration (consumes more  memory) in java.

Logic>
We will maintain one extra array of size 100 (i.e. tempAr), after initialization all the values in tempAr will be 0.

Start iterating on ar,
In first iteration i=0 and let’s say we obtain 3 at ar
i.e.   i=33, than make tempAr=1;
In first iteration i=1 and we obtain 25 at ar
i.e. i=27, than make tempAr=1;

Once we have completed iteration on ar,
we will iterate from 1 to 100  (keep it in variable i),
if tempAr[i]==0, number is missing in array.
if tempAr[i]==1, number is there in array.

Hence, because of tempAr we will end up consuming extra memory, but process for finding missing numbers will be quick in java.

Full Program/SourceCode/ Example to Find missing number between 1 to 100 in unsorted Array - consumes more memory (but quick) in java >
 /** Copyright (c), AnkitMittal  JavaMadeSoEasy.com */ public class FindMissingNumberInUnSortedArray2{    static int ar[]={33,27,5,8,44,24}; //given array       public static void main(String[] args) {           System.out.print("given array : ");           for (int j = 0; j < ar.length; j++)                  System.out.print(ar[j] +" "); // display it                     displayMissing();          }       /*    * Method for displaying missing number in given range.    */    static public void displayMissing(){                     int tempAr[]=new int;           for (int j = 0; j < ar.length; j++){ /*make indexes of tempAr corresponding to value found in ar equal to 1.                                                                               i.e if i=22, than make tempAr=1;                                                                               if i=25, than make tempAr=1; */                  tempAr[ar[j]]=1;           }                     System.out.print("\nNumbers missing between 1 to 100 in array :  ");                     for(int i=1;i

Having any doubt? or you you liked the tutorial! Please comment in below section.