Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
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.
Preprocessor
Problem: rstring
Write a program to count the occurrence of each distinct item in the array?
a6
Encrption & Decryption C#
Order of Ops 6.5 (added brackets)
shorten file paths in a commandline using regex
HSC
Fibonacci Recursive C#
hello,world
Please log in to post a comment.