Problem · Simulation

Determine the Elimination Order (MLE)

Learn this problem
MediumQuora logoQuoraINTERNOA

Problem statement

Given the competition results, determine the elimination order. For example:

Input:

[["Tom 20", "Sam 10"], ["Sam 20", "Tom 10"]]

In the first round, Tom takes the longest time and gets eliminated. In the second round, only Sam remains, so their score is valid and added to the output list.

Output:

["Tom", "Sam"]

Edge case: If scores are tied, all tied contestants are eliminated simultaneously.

Function

determineEliminationOrder(results: String[][]) → String[]

Examples

Example 1

results = [["Tom 20", "Sam 10"], ["Sam 20", "Tom 10"]]return = ["Tom", "Sam"]

In the first round, Tom takes the longest time and gets eliminated. In the second round, only Sam remains, so their score is valid and added to the output list.

More Quora problems

drafts saved locally
public String[] determineEliminationOrder(String[][] results) {
  // write your code here
}
results[["Tom 20", "Sam 10"], ["Sam 20", "Tom 10"]]
expected["Tom", "Sam"]
checking account