Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Find the missing number in an array2
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { int [] arr = new int []{1,3,4,5,6,7,8,9}; int num = findMissingnum(arr); Console.Write(num); } public static int findMissingnum(int[] a) { int i=0; for(int j=1; j<a.Length; j++) { //Console.WriteLine(a[j] - a[i]); if((a[j] - a[i]) > 1) { return a[i]+1; } i++; } return 0; } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
CommandForce
more or less
Plt-D v.0.8
Insertion Sort
String combinations
Task 1_4
Concatenate string with null.
ZeroMatrix
C# queue
hihi
stackse - search stackoverflow differently
Please log in to post a comment.