We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution {
static SortedSet sortedSet = new SortedSet();
static void Main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);
int Q = int.Parse(Console.ReadLine().TrimEnd());
for (int i = 1; i <= Q; i++) {
string[] arr = Console.ReadLine().Split(' ');
switch(arr[0]){
case "1":
sortedSet.Add(int.Parse(arr[1]));
break;
case "2":
sortedSet.Remove(int.Parse(arr[1]));
break;
case "3":
textWriter.WriteLine(sortedSet.Min);
break;
}
}
textWriter.Flush();
textWriter.Close();
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
QHEAP1
You are viewing a single comment's thread. Return to all comments →
C# code using SortedSet
using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static SortedSet sortedSet = new SortedSet();
}