Now find missing numbers between array elements
$ count = 0 ; $ curr = 1 ; while ( $ count < $ k && $ i < $ n ) { if ( $ arr [ $ i ] != $ curr ) { echo $ curr , " " ; $ count ++ ; } else $ i ++ ; $ curr ++ ; }