Find the minimum changes so no two adjacent engineers in a circle choose the same option.
Unlock detailed company stats for this questionUpgrade
Engineers at Uber sit around a circular table playing a modified Rock-Paper-Scissors game. Each engineer secretly chooses 'R', 'P' or 'S'. Two neighbors tie if they choose the same option. You may ask any engineer to change their choice to either of the other two options. Compute the minimum number of engineers whose choice must change so that no two adjacent engineers choose the same option. The table is circular, so the first and last engineers are neighbors. Signature: int minChanges(string choices); choices[i] in {'R','P','S'}, 3 <= n <= 2 * 10^5. Example 1: PRSSP -> 2. Example 2: RRRRRRR -> 4. Example 3: RSPRPSPRS -> 0 (no adjacent engineers choose the same option).
Format · Uber SDE-1 DSA round.
Community answers
No answers contributed by the community yet.
Related courses

Course

Course
Course
