Largest Share from the Circular Pizza Selection Game
Quick Overview
Largest Share from the Circular Pizza Selection Game. The circular slices array has length3*n. Repeatedly choose any remaining slice for yourself; Alice then takes its immediate remaining anticlockwise neighbor and Bob its immediate remaining clockwise neighbor.
Largest Share from the Circular Pizza Selection Game
Company: Infosys
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Other
### Problem
The circular slices array has length 3*n. Repeatedly choose any remaining slice for yourself; Alice then takes its immediate remaining anticlockwise neighbor and Bob its immediate remaining clockwise neighbor. Continue until no slices remain. Return the largest total size you can collect.
```cpp
class Solution {
public:
int maxSizeSlices(vector<int>& slices);
};
```
### Examples
**Example 1:**
```text
Input: slices = [2,1,2,1,2,1]
Output: 4
Explanation: Choose the size2 at index0, removing its neighboring ones; then choose either remaining size2. You collect4, the sum of the two largest possible chosen sizes.
```
**Example 2:**
```text
Input: slices = [1,4,2]
Output: 4
Explanation: There is one round; taking the size4 leaves the other two slices for Alice and Bob.
```
### Constraints
- slices.length equals 3*n, lies between 1 and 500,and is divisible by 3.
- `1 <= slices[i] <= 1000`.
### Contract considerations
Alice and Bob take neighbors in the remaining circle after each choice, not arbitrary slices.
```hint Read the boundary condition
Follow both neighbors in the remaining circle after every choice. The objective is your total over the complete game.
```
### Boundary reminders
Alice and Bob take neighbors in the remaining circle after each choice, not arbitrary slices.
Overview: Largest Share from the Circular Pizza Selection Game. The circular slices array has length3*n. Repeatedly choose any remaining slice for yourself; Alice then takes its immediate remaining anticlockwise neighbor and Bob its immediate remaining clockwise neighbor.
Largest Share from the Circular Pizza Selection Game
Infosys
Source window: 0–3 months · as of Oct 21, 2026
hardSoftware EngineerOtherCoding & Algorithms
0
0
Problem
The circular slices array has length 3*n. Repeatedly choose any remaining slice for yourself; Alice then takes its immediate remaining anticlockwise neighbor and Bob its immediate remaining clockwise neighbor. Continue until no slices remain. Return the largest total size you can collect.
class Solution {
public:
int maxSizeSlices(vector<int>& slices);
};
Examples
Example 1:
Input: slices = [2,1,2,1,2,1]
Output: 4
Explanation: Choose the size2 at index0, removing its neighboring ones; then choose either remaining size2. You collect4, the sum of the two largest possible chosen sizes.
Example 2:
Input: slices = [1,4,2]
Output: 4
Explanation: There is one round; taking the size4 leaves the other two slices for Alice and Bob.
Constraints
slices.length equals 3*n, lies between 1 and 500,and is divisible by 3.
1 <= slices[i] <= 1000
.
Contract considerations
Alice and Bob take neighbors in the remaining circle after each choice, not arbitrary slices.
Boundary reminders
Alice and Bob take neighbors in the remaining circle after each choice, not arbitrary slices.