Problem Statement
Definition
- Class:
- Top5
- Method:
- topNames
- Parameters:
- int[], String[]
- Returns:
- String
- Method signature:
- String topNames(int[] score, String[] name)
- (be sure your method is public)
Notes
- the first score correponds to the first name, the second to the second, etc.
Constraints
- score and name contain the same number of elements
- the number of elements is between 1 and 50 inclusive
- each element of score is between 1 and 1000 inclusive
- each element of name contains only letters
- each element of name contains between 1 and 20 characters inclusive
- the elements of name are distinct
Examples
{5,5,7,2,8,3}
{"a","z","X","A","Tom","Jim"}
Returns: "a, z, X, Tom, Jim"
The score of 2 is not in the top 5, so A is eliminated.
{3}
{"Stickberger"}
Returns: "Stickberger"
{1,1,8,1,8,1,1}
{"Y","T","R","E","W","Q","QQ"}
Returns: "Y, T, R, E, W, Q, QQ"
{8,8,8,8,8,9}
{"a","b","c","d","e","f"}
Returns: "a, b, c, d, e, f"
{8,8,8,8,8,7}
{"a","b","c","d","e","f"}
Returns: "a, b, c, d, e"
{1000,3,3,3,3,3,3,3,8,9,1,2,3,4,5,3,1}
{"a","b","c","d","e","f","g","h","i","j","k","n","m","q","r","s","t"}
Returns: "a, i, j, q, r"
{3,3}
{"BBBBBBBBBBBBBBBBBBB","AAAAAAAAAAAAAAAAAAAA"}
Returns: "BBBBBBBBBBBBBBBBBBB, AAAAAAAAAAAAAAAAAAAA"
{1000,1000,1000,1000,1000,1000,999}
{"a","b","c","d","e","f","g"}
Returns: "a, b, c, d, e, f"
{6,5,4,3,2}
{"al","tom","bob","qq","john"}
Returns: "al, tom, bob, qq, john"
{77,77,77,77}
{"purple","brown","green","yellow"}
Returns: "purple, brown, green, yellow"
{99,1,2,3,4,5,6,7,8,9,9,9,9,9,9,9,9,9,9,10,3,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,3,3,3,3,3,3,3,4}
{"bo","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","y"}
Returns: "bo, i, j, k, l, m, n, o, p, q, r, s, u, v, w, x, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q"
{123,123,123,123,123,123,123,123}
{"z","y","xxxxxxxxxxxxxxxxxxxx","w","a","b","c","d"}
Returns: "z, y, xxxxxxxxxxxxxxxxxxxx, w, a, b, c, d"