ORIGINAL CODING QUESTION
Round-table mentor picks
n mentors sit around a round table, each with a non-negative rating. Invite mentors so that no two invited mentors sit side by side; seat n-1 sits beside seat 0. A lone mentor (n = 1) may be invited. Return the largest total rating of the invited mentors.
Original exercise · medium. Editorial role relevance does not imply a company has asked this question.
Input and output
n, then n ratings in seat order.
Constraints
1 ≤ n ≤ 12; 0 ≤ rating ≤ 100.
Example 1
Input
5 4 1 2 7 5
Output
11
Seats 0 and 3 give 11; seats 0 and 4 are neighbours.
Example 2
Input
3 6 6 6
Output
6
On a three-seat table any two seats touch, so only one mentor can be invited.
Explain your approach
Explain your time and auxiliary space complexity. Which input makes your algorithm work hardest?
Private grading inputs, expected outputs and canonical reference implementations are withheld. Authored expected outputs were cross-checked with independent reference oracles; compiler/runtime behavior still needs a verified execution provider.
Hint 1
The circle only adds one constraint: seat 0 and seat n-1 cannot both be chosen.
Hint 2
Solve the straight-row version twice: once without seat 0 and once without seat n-1.
Hint 3
Take the larger result, and treat n = 1 separately.
Practice this question
Save your work privately, explain decisions and return to your revision queue.
Open practice workspaceBrowse the question library →