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 13:30
Select the correct answer from each drop-down menu. which types of computer networks are bigger as well as smaller than a man? a man is a network of computers that covers an area bigger than a , but smaller than a .
Answers: 1
question
Computers and Technology, 24.06.2019 17:00
What are some examples of what can be changed through options available in the font dialog box? check all that apply. font family italicizing bolding pasting drop shadow cutting character spacing special symbols
Answers: 2
question
Computers and Technology, 24.06.2019 22:00
Difference between ancient and modern mode of information transmission
Answers: 1
question
Computers and Technology, 25.06.2019 05:30
The piston ring isn't a completely solid ring; instead, it's usually split at one point. this split or gap in the ring is called the a. ring spacing. b. ring clearance. c. ring end gap. d. ring side clearance.
Answers: 2
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, 26.06.2020 16:01
question
World Languages, 26.06.2020 16:01
question
Mathematics, 26.06.2020 16:01
Questions on the website: 13722361