Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Find the missing number in an array1
//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[4]{1,2,4,5}; int n=5; int num = findMissingNum(arr,n); Console.Write("Missing " + num); } public static int findMissingNum(int[] arr, int n) { if(arr.Length < n) { int j=1; for(int i=0; i< arr.Length; i++) { if((arr[j]-arr[i] >1) && j<arr.Length) { return (arr[i]+1); } j = j+1; } } return 0; } } }
run
|
edit
|
history
|
help
0
bla bla
const
My quad calc
compiled prog
teste
DateTime
Write a program to filter distinct items from the array
c++
Dynamic properties in Dynamic object
Remove Duplicate Ignore Case