GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.hackerrank.com — Java Priority Queue | HackerRank 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. In computer science, a priority queue is an abstract data type which is like a regular queue, but where additionally each element has a "priority" associated with it. In a priority queue, an element with high priority is served before an element with low priority. - Wikipedia In this problem we will test your knowledge on Java Priority Queue. There are a number of students in a school who wait to be served. Two types of events, ENTER and SERVED, can take place which are described below.
A unique id is assigned to each student entering the queue. The queue serves the students based on the following criteria (priority criteria):
Create the following two classes:
Input Format The first line contains an integer, , describing the total number of events. Each of the subsequent lines will be of the following two forms:
The locked stub code in the editor reads the input and tests the correctness of the Student and Priorities classes implementation. Constraints Output Format The locked stub code prints the names of the students yet to be served in the priority order. If there are no such student, then the code prints Sample Input 0 12 ENTER John 3.75 50 ENTER Mark 3.8 24 ENTER Shafaet 3.7 35 SERVED SERVED ENTER Samiha 3.85 36 SERVED ENTER Ashley 3.9 42 ENTER Maria 3.6 46 ENTER Anik 3.95 49 ENTER Dan 3.95 50 SERVED Sample Output 0 Dan Ashley Shafaet Maria Explanation 0 In this case, the number of events is 12. Let the name of the queue be Q.
As all events are completed, the name of each of the remaining students is printed on a new line. Cookie support is required to access HackerRankSeems like cookies are disabled on this browser, please enable them to open this website |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |