FastPrepFastPrep
Problem Brief

Get Biggest Lions

OA

As a lion trainer, you are taking part in an international lion exhibition. During the event lions from different teams enter and exit the showroom where lion experts inspect and score them. Lions do not enter the showroom all at once, as that would cause too much commotion. The organizers of the event let them in and out based on a predefined schedule. Before the show you are given the schedule for your lions, but not for the others. During the show, however, you can observe all lions entering and exiting the room.

Based on your experience, you believe that judges tend to award the largest lions with the highest scores. Before the final results are out, you want to estimate your chances of winning this competition.

Problem Statement

Complete the following:

  • The LionCompetition class constructor that accepts lion descriptions and the private schedule for your lions.
  • The LionEntered and LionLeft methods that are called whenever a new lion enters or leaves the room.
  • The getBiggestLions method that, for the current time, returns a list of our lions in the room that are at least as large as the largest lion from competing teams in the room, sorted alphabetically.

Function definitions

LionCompetition class constructor parameters:

  • lions - list of elements describing your lions:
    • name - string representing a name of the lion
    • height - height of the lion
  • schedule - a private schedule of when your lions enter and leave the show room
    • name - string representing a name of the lion
    • enterTime - number of minutes since the start of the show when the lion will enter the room
    • exitTime - number of minutes since the start of the show when the lion will exit the room

LionEntered function parameters:

  • currentTime - number of minutes since the start of the show
  • height - height of the lion that entered the room

LionLeft function parameters:

  • currentTime - number of minutes since the start of the show
  • height - height of the lion that left the room

Constraints

Limits and guarantees your solution can rely on.

  • Subsequent invocations of LionLeft and LionEntered methods are always called in order, according to the currentTime parameter.
  • The schedule is strictly followed - your lions enter and exit the room exactly at their specified times.
  • The lion inspection (invocation of the getBiggestLions method) takes place either before or after all lions scheduled to enter or leave the room at a given minute did that - never in between.
  • Lion names are unique.
  • Times (currentTime, enterTime and exitTime) are always whole numbers (and multiple events can occur at the same time).
  • A single lion enters the room only once during the show.
class LionCompetition {
    // write your constructor here

    public void LionEntered(int currentTime, int height) {
        // write your code here
    }

    public void LionLeft(int currentTime, int height) {
        // write your code here
    }

    public List<String> getBiggestLions() {
        // write your code here
    }
}

Sign in to submit your solution.