|
2 | 2 |
|
3 | 3 | import java.util.Arrays;
|
4 | 4 |
|
5 |
| -/** |
6 |
| - * 1388. Pizza With 3n Slices |
7 |
| - * |
8 |
| - * There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows: |
9 |
| - * You will pick any pizza slice. |
10 |
| - * Your friend Alice will pick next slice in anti clockwise direction of your pick. |
11 |
| - * Your friend Bob will pick next slice in clockwise direction of your pick. |
12 |
| - * Repeat until there are no more slices of pizzas. |
13 |
| - * Sizes of Pizza slices is represented by circular array slices in clockwise direction. |
14 |
| - * |
15 |
| - * Return the maximum possible sum of slice sizes which you can have. |
16 |
| - * |
17 |
| - * Example 1: |
18 |
| - * Input: slices = [1,2,3,4,5,6] |
19 |
| - * Output: 10 |
20 |
| - * Explanation: Pick pizza slice of size 4, Alice and Bob will pick slices with size 3 and 5 respectively. Then Pick slices with size 6, finally Alice and Bob will pick slice of size 2 and 1 respectively. Total = 4 + 6. |
21 |
| - * |
22 |
| - * Example 2: |
23 |
| - * Input: slices = [8,9,8,6,1,1] |
24 |
| - * Output: 16 |
25 |
| - * Output: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8. |
26 |
| - * |
27 |
| - * Example 3: |
28 |
| - * Input: slices = [4,1,2,5,8,3,1,9,7] |
29 |
| - * Output: 21 |
30 |
| - * |
31 |
| - * Example 4: |
32 |
| - * Input: slices = [3,1,2] |
33 |
| - * Output: 3 |
34 |
| - * |
35 |
| - * Constraints: |
36 |
| - * 1 <= slices.length <= 500 |
37 |
| - * slices.length % 3 == 0 |
38 |
| - * 1 <= slices[i] <= 1000 |
39 |
| - * */ |
40 | 5 | public class _1388 {
|
41 | 6 | public static class Solution1 {
|
42 | 7 | public int maxSizeSlices(int[] slices) {
|
|
0 commit comments