stictt

C#

Mar 4th, 2021 (edited)
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1.     class Test
  2.     {
  3.         public int NotContains(int[] array)
  4.         {
  5.             int count = 0;
  6.             if (array == null) return 1;
  7.            
  8.             array = array.Where(x => x > 0).OrderBy(x => x).ToArray();
  9.            
  10.             foreach (var item in array.Length.GetCollection())
  11.             {
  12.                 if (array[count++] != item)
  13.                 {
  14.                     return item;
  15.                 }
  16.             }
  17.             return 0;
  18.         }
  19.     }
  20.    static class test2
  21.    {
  22.         public static IEnumerable<int> GetCollection(this int x)
  23.         {
  24.             for (int i = 0; i < x - 1 ; i++)
  25.             {
  26.                 yield return i;
  27.             }
  28.         }
  29.    }
Add Comment
Please, Sign In to add comment