SHARE
TWEET

Untitled

a guest Jul 16th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class Program
  6. {
  7. public static void Main(string[] args)
  8. {
  9. var numbersCount = int.Parse(Console.ReadLine()); //6
  10. var nums = Console.ReadLine(); //1 1 1 2 2 0
  11. var numsArr = nums.Split(' ').Select(n => Convert.ToInt32(n)).ToArray();
  12.  
  13. var queriesCount = int.Parse(Console.ReadLine()); //6
  14. var numsDicOcc = new List<Dictionary<int, string>>();
  15.  
  16. for (var j = 1; j <= queriesCount; j++)
  17. {
  18.     var x = int.Parse(Console.ReadLine());
  19.     var occ = numsArr.Count(p => p == x);
  20.     var dic2 = new Dictionary<int, string> {{x, occ.ToString()}};
  21.     if (occ == 0) numsDicOcc.Add(new Dictionary<int, string> { { x, "NOT PRESENT" } });
  22.     else if (!numsDicOcc.Contains(dic2))
  23.     numsDicOcc.Add(dic2);
  24.     else numsDicOcc[j][x] = occ.ToString();
  25.  }
  26.  
  27.  for (var index = 0; index < numsDicOcc.Count; index++)
  28.  Console.WriteLine(numsDicOcc[index].First().Value);
  29.  }
  30. }
RAW Paste Data
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