TCS OA-7 2024
Problem Description
Given two arrays, score
(an array of integers) and names
(an array of strings representing candidate names), where each names[i]
corresponds to a score[i]
. Assume that 0≤i<n and n=score.size()=names.size(). Print the name of the candidate with the highest score.
Input Format
- The first line contains an integer N, representing the length of the array (score and names).
- The second line contains N space-separated integers, representing score.
- The third line contains N space-separated strings, representing names.
Output Format
Print the name of the candidate with highest score.
Constraints
- 1 ≤ N ≤ 10⁵
- 1 ≤ score[i] ≤ 10⁵
- 1 ≤ names[i].length ≤ 100
Example
Sample Input:
4
[100,95,102,120]
["Peter","John","Alice","Joe"]
Sample Output:
Joe
Explanation:
Joe has highest score of 120 as compared to Peter, John and Alice.