G2A Many GEOs
SHARE
TWEET

Untitled

a guest Apr 8th, 2020 148 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   public int CountElements(int[] arr)
  2.         {
  3.             var dict = new Dictionary<int, int>();
  4.             var sum = 0;
  5.             foreach (var num in arr)
  6.             {
  7.                 if (dict.TryGetValue(num, out var count))
  8.                 {
  9.                     dict[num] = count + 1;
  10.                 }
  11.                 else
  12.                 {
  13.                     dict.Add(num, 1);
  14.                 }
  15.             }
  16.  
  17.             foreach (var (key, value) in dict)
  18.             {
  19.                 if (dict.TryGetValue(key + 1, out var _value))
  20.                 {
  21.                     sum += value;
  22.                 }
  23.             }
  24.  
  25.             return sum;
  26.         }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top