subject

There are 10 floors in a hotel (numbered from 0 to 9). on each floor there are 26 rooms, each marked with a capital letter of the english alphabet (from "a" to "z"). your task is to compute which room was booked most frequently, based on a list of room reservations. the list of reservations consists of n three-character strings. the first character of the string is "+" or "−", which describes whether the room was booked or freed. the second and third characters correspond to the number of the floor and letter of the room, respectively. for example "+4c" means that room c on the 4th floor has just been booked, and "−0g" means that room g on the 0th floor has been freed. you may assume that the list describes a correct sequence of bookings in chronological order; that is, only free rooms can be booked and only booked rooms can be freed. all rooms are initially free. note that this doesn't mean that all rooms have to be free at the end. write a function: class solution { public string solution(string[] a); } that, given an array a consisting of n strings, representing the list of bookings, returns a two-character string consisting the floor number and letter of the room that was booked the most times. it is possible that more than one room might have been booked the same, maximum number of times; in this case, return the one whose identifier is the smallest alpha-numerically. write in java. examples: given a = ["+1a", "−1a", "+3f", "−3f", "+3f", "+8x"], your function should return "3f". room 3f was booked twice, while rooms 1a and 8x were booked only once. note that rooms 3f and 8x are still booked at the end. given a = ["+1a", "+3f", "+8x", "−1a", "−3f", "−8x"], your function should return "1a". all of the rooms "1a", "3f" and "8x" were booked once. "1a" is the smallest alpha-numerically out of them. given a = ["+0a"], your function should return "0a". given a = ["+9z", "−9z", "+9z", "−9z", "+9z", "+3b"], your function should return "9z", as room 9z was booked three times. assume that: n is an integer within the range [1..600]; each element of array a is a string consisting of three characters: "+" or "−", a digit ("0"-"9"), and uppercase english letter ("a"-"z"); the sequence is correct, that is every booked room was previously free and every freed room was previously booked. in your solution, focus on correctness. the performance of your solution will not be the focus of the assessment.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 15:30
1. ask the user how many questions are in the quiz. 2. ask the user to enter the key (that is, the correct answers). there should be one answer for each question in the quiz, and each answer should be an integer. e.g., 34 7 13 100 81 3 9 10 321 12 might be the key for a 10-question quiz. you will need to store the key in an array. 3. ask the user to enter the answers for the quiz to be graded. there needs to be one answer for each question. note that these answers do not need to be stored; each answer can simply be compared to the key as it is entered. 4. when the user has entered all of the answers to be graded, print the number correct and the percent correct. 5. add a loop so that the user can grade any number of quizzes with a single key. after the results have been printed for each quiz, ask "grade another quiz? (y/n)." note: you only have one array (the key). you are not creating a new key for each set of quiz answers.
Answers: 3
question
Computers and Technology, 24.06.2019 10:00
In which view can you see speaker notes?
Answers: 1
question
Computers and Technology, 24.06.2019 15:00
Who introduced the concept of combining artificial and natural light in the studio
Answers: 1
question
Computers and Technology, 24.06.2019 16:00
What is a dashed line showing where a worksheet will be divided between pages when it prints? a freeze pane a split box a page break a print title
Answers: 1
You know the right answer?
There are 10 floors in a hotel (numbered from 0 to 9). on each floor there are 26 rooms, each marked...
Questions
question
Mathematics, 27.03.2020 19:54
question
Mathematics, 27.03.2020 19:54
question
Chemistry, 27.03.2020 19:54
Questions on the website: 13722367