Employee With the Highest Salary
Problem statement
You are given two arrays of equal length:
names[i]is the name of thei-th employee.salaries[i]is that employee's salary.
Return the name of the employee with the highest salary. If several employees share the highest salary, return the name that appears first in the input.
Function
highestSalaryName(names: String[], salaries: int[]) → StringExamples
Example 1
names = ["Ava","Ben","Chen"]salaries = [70000,92000,85000]return = "Ben"Ben has the largest salary, 92000.
Example 2
names = ["Mina","Noah","Omar"]salaries = [50000,61000,61000]return = "Noah"Noah and Omar tie for the highest salary, so return the earlier name.
Example 3
names = ["Zoe"]salaries = [0]return = "Zoe"The only employee is the answer.
Constraints
1 <= names.length = salaries.length <= 10^5.names[i]is non-empty.0 <= salaries[i] <= 10^9.