The check-in and check-out times of each guest for a hotel are given as input. You need to output the maximum number of guests staying at a time at the hotel. [Hint]: Sort the check-in array Sort the check-out array Merge the sorted arrays   Keep track of the number of guests at the hotel during each iteration. To do this traverse the merged array. When someone check-ins, guest count increases by one, when someone check-outs, guest count decreases by one. And also keep track of the maximum number at any time Sample Input Check-in times

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question

The check-in and check-out times of each guest for a hotel are given as input. You need to output the maximum number of guests staying at a time at the hotel.

[Hint]:

  1. Sort the check-in array
  2. Sort the check-out array
  3. Merge the sorted arrays  
  4. Keep track of the number of guests at the hotel during each iteration. To do this traverse the merged array. When someone check-ins, guest count increases by one, when someone check-outs, guest count decreases by one.
  5. And also keep track of the maximum number at any time
  6. Sample Input

    Check-in times

    Check out times

    Sample Output

    {2.00, 2.10, 3.00, 3.20, 3.50, 5.00}

    {2.30, 3.40, 3.20, 4.30, 4.00, 5.20}

    2

    {9.00, 9.40, 9.50, 11.00, 15.00, 18.00}

    {9.10, 12.00, 11.20, 11.30, 19.00, 20.00}

    3

Your answer

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Fundamentals of Multithreaded Algorithms
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning