|
1 | 1 | --- |
2 | 2 | title: One question daily 2293. Great mini game |
3 | | -date: '2024.01.01 0:00' |
| 3 | +date: "2024.01.01 0:00" |
4 | 4 | tags: |
5 | 5 | - - Python |
6 | 6 | - - solved |
7 | 7 | - answer |
8 | 8 | abbrlink: 9df6242c |
9 | | -category: |
| 9 | +category: null |
| 10 | +docId: mssz5wgh368yp55qcvs1op5e |
10 | 11 | --- |
11 | | -Although it is a simple question,But there are recursive ideas。 |
| 12 | + |
| 13 | +Although it is a simple question,But there are recursive ideas。 |
12 | 14 |
|
13 | 15 | Constantly convert the one -dimensional list into a two -dimensional list for operation(This can be avoidedindexChaos caused by changes) |
14 | 16 |
|
15 | | -Then useflagCount,Comparison of maximum and minimum values。 |
| 17 | +Then useflagCount,Comparison of maximum and minimum values。 |
16 | 18 |
|
17 | 19 | Just return to the end,Although it must be returned to a number,Still‘nums[0]’To avoid warning。 |
18 | 20 |
|
19 | | - |
20 | 21 | ```html |
21 | | -2293. Great mini game |
22 | | -Simple |
23 | | -39 |
24 | | -company |
25 | | -Google Google |
26 | | -Give you a bidding 0 Started integer array nums ,Its length is 2 Power。 |
27 | | - |
28 | | -right nums Execute the following algorithm: |
29 | | - |
30 | | -set up n equal nums length,if n == 1 ,termination Algorithm。otherwise,create A new integer array newNums ,The length of the new array is n / 2 ,Bidding from 0 start。 |
31 | | -right于满足 0 <= i < n / 2 Every even Bidding i ,Will newNums[i] Assignment for min(nums[2 * i], nums[2 * i + 1]) 。 |
32 | | -right于满足 0 <= i < n / 2 Every odd number Bidding i ,Will newNums[i] Assignment for max(nums[2 * i], nums[2 * i + 1]) 。 |
33 | | -use newNums replace nums 。 |
34 | | -From steps 1 start repeat the whole process。 |
35 | | -After executing the algorithm,return nums The remaining numbers。 |
36 | | - |
37 | | - |
38 | | - |
39 | | -Exemplary example 1: |
40 | | - |
41 | | - |
42 | | - |
43 | | -enter:nums = [1,3,5,2,4,8,2,2] |
44 | | -Output:1 |
45 | | -explain:repeat执行算法会得到下述数组。 |
46 | | -first round:nums = [1,5,4,2] |
47 | | -second round:nums = [1,4] |
48 | | -Third round:nums = [1] |
49 | | -1 Is the last number left,return 1 。 |
50 | | -Exemplary example 2: |
51 | | - |
52 | | -enter:nums = [3] |
53 | | -Output:3 |
54 | | -explain:3 Is the last number left,return 3 。 |
55 | | - |
56 | | - |
57 | | -hint: |
58 | | - |
59 | | -1 <= nums.length <= 1024 |
60 | | -1 <= nums[i] <= 109 |
61 | | -nums.length yes 2 Power |
62 | | - |
| 22 | +2293. Great mini game Simple 39 company Google Google Give you a bidding 0 |
| 23 | +Started integer array nums ,Its length is 2 Power。 right nums Execute the |
| 24 | +following algorithm: set up n equal nums length,if n == 1 ,termination |
| 25 | +Algorithm。otherwise,create A new integer array newNums ,The length of the new |
| 26 | +array is n / 2 ,Bidding from 0 start。 right于满足 0 <= i < n / 2 Every even |
| 27 | +Bidding i ,Will newNums[i] Assignment for min(nums[2 * i], nums[2 * i + 1]) 。 |
| 28 | +right于满足 0 <= i < n / 2 Every odd number Bidding i ,Will newNums[i] |
| 29 | +Assignment for max(nums[2 * i], nums[2 * i + 1]) 。 use newNums replace nums 。 |
| 30 | +From steps 1 start repeat the whole process。 After executing the |
| 31 | +algorithm,return nums The remaining numbers。 Exemplary example 1: enter:nums |
| 32 | += [1,3,5,2,4,8,2,2] Output:1 explain:repeat执行算法会得到下述数组。 first |
| 33 | +round:nums = [1,5,4,2] second round:nums = [1,4] Third round:nums = [1] 1 Is |
| 34 | +the last number left,return 1 。 Exemplary example 2: enter:nums = [3] |
| 35 | +Output:3 explain:3 Is the last number left,return 3 。 hint: 1 <= |
| 36 | +nums.length <= 1024 1 <= nums[i] <= 109 nums.length yes 2 Power |
63 | 37 | ``` |
64 | 38 |
|
65 | 39 | ```python |
|
0 commit comments