Advertisement
Guest User

02. Sets of Elements

a guest
Jan 24th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace SETS_AND_DICTIONARIES_ADVANCED
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Dictionary<int, int> dict = new Dictionary<int, int>();
  11.             int n = int.Parse(Console.ReadLine());
  12.  
  13.             for (int i = 0; i < n; i++)
  14.             {
  15.                 int curr = int.Parse(Console.ReadLine());
  16.  
  17.                 if (!dict.ContainsKey(curr))
  18.                 {
  19.                     dict[curr] = 0;
  20.                 }
  21.                 dict[curr]++;
  22.             }
  23.             foreach (var kvp in dict)
  24.             {
  25.                 if (kvp.Value % 2 == 0)
  26.                 {
  27.                     Console.WriteLine(kvp.Key);
  28.                     break;
  29.                 }
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement