Solved LeetCode program · 361 of 1,000
#0486 · Predict the Winner
Original English source
The numbers is a list of 1, 5, 2. The size is 3. The table is a list of 9 zeros.
For every span from 1 to size.
For every start from 0 to size minus span.
The finish is start plus span minus 1. If start is finish, set item (start times size plus start) of table to item start of numbers.
If start is not finish.
The leftindex is (start plus 1) times size plus finish. The rightindex is start times size plus finish minus 1. The left is item start of numbers minus item leftindex of table. The right is item finish of numbers minus item rightindex of table. If left is more than right, set item (start times size plus finish) of table to left, otherwise set item (start times size plus finish) of table to right.
The outcome is item (size minus 1) of table. If outcome is at least 0, show true, otherwise show false.
Expected stdout
false