-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20-FindMissingOddNumbers.cs
44 lines (40 loc) · 1.07 KB
/
20-FindMissingOddNumbers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Text;
namespace HackerRank
{
public class FindMissingOddNumbers_Result
{
public static void MissingOddNumber(int[] arr)
{
Array.Sort(arr);
List<int> lstNumbers = new List<int>();
for(int i = 0; i < arr.Length; i++)
{
if( i+1 < arr.Length && arr[i+1]!=arr[i]+2)
{
lstNumbers.Add(arr[i] + 2);
}
}
if (lstNumbers.Count > 0)
{
foreach(var digit in lstNumbers)
{
Console.WriteLine($"{digit}");
}
}
else
{
Console.WriteLine("No Missing Number in element!");
}
}
}
public class FindMissingOddNumbers_Solution
{
public static void Input()
{
int[] oddNumber = new int[] { 9, 7, 3, 13, 17};
FindMissingOddNumbers_Result.MissingOddNumber(oddNumber);
}
}
}