FastPrepFastPrep
Problem Brief

Filter by Threshold and Return Name with Max Score

FULLTIMEOA

Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem.

Problem

Given records records = [(name, score), ...] and an integer threshold:

Filter out all records with score > threshold (keep score <= threshold).

Among the remaining records, find the record with the maximum score and output its name.

Constraints:

At least one record satisfies score <= threshold.

name is a no-space string, score is an integer.

Input:

Line 1: integer n

Line 2: integer threshold

Next n lines: name score

Output:

One line: the name with the maximum score among those <= threshold.

Example: Input:

4

80

alice 50

bob 90

cindy 80

dave 70

Output:

cindy

Example

Input

4

80

alice 50

bob 90

cindy 80

dave 70

Output

cindy

Function Description

Complete solveFilterThresholdMaxScore. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters.

1Example 1

Input
input = "4\n80\nalice 50\nbob 90\ncindy 80\ndave 70"
Output
["cindy"]
Explanation

The returned string array must match the expected standard output lines for the sample input.

Constraints

Limits and guarantees your solution can rely on.

Use the limits and requirements stated in the prompt.

public String[] solveFilterThresholdMaxScore(String input) {
    // write your code here
}
Input

input

"4\n80\nalice 50\nbob 90\ncindy 80\ndave 70"

Output

["cindy"]

Sign in to submit your solution.