UBER Coding Question – Solved

8 Live
Academic Decathlon Students are being selected for an academic decathlon team at a school. Each student has a skill level, and for a team to be uniform, the difference between any two consecutive skill levels (when arranged in increasing order) must be either 0 or 1. Your task is to find the maximum possible team size. Example skills = [0, 12, 13, 9, 14] Valid teams, when sorted, are (9, 10) and (12, 13, 14). These teams have sizes 2 and 3, respectively, so the maximum team size is 3. Function Description Complete the function findMaxTeamSize with the following parameter: - int skills[n]: the skill levels of each student Returns - int: the maximum possible size of the team Constraints - 1 ≀ n ≀ 10^5 - 1 ≀ skills[i] ≀ 10^9 Input Format for Custom Testing Sample Case 0 Sample Input skills[] size n = 4 skills = [4, 13, 2, 3] Sample Output 3 Explanation There are two valid teams possible: (2, 3, 4) and (13). These have team sizes of 3 and 1, respectively. So the maximum possible team size is 3.

Asked in: UBER

Image of the Question

Question Image Question Image Question Image

All Testcases Passed βœ”



No images available for this passcode.

Solution


Please login to view the solution


Related Questions

| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |
| Undirected Coloured Graph Shortest Path You are given an undirected weight… |
| Village Voyage A computer game "Village Voyage" has N villages (labeled 1 to… |
| Sum of Arrays Given two arrays each of length n, arr1 and arr2, in one opera… |
| Count Swaps During Custom Sorting Analyze the efficiency of the following so… |
| Stacey is coordinating a beach clean-up event with her university's Women in ST… |