LeetCode Weekly Contest 236
| Rank | Name | Score | Finish Time | Q1 (3) | Q2 (5) | Q3 (5) | Q4 (6) |
|---|---|---|---|---|---|---|---|
| 1513 / 12115 | YoungForest | 12 | 0:45:18 | 0:02:57 | 0:08:59 | 0:40:18 1 | null |
1822. Sign of the Product of an Array
A warm-up problem. Count how many negative numbers there are and whether there is a 0.
1 | class Solution: |
Time complexity: O(N),
space complexity: O(1).
1823. Find the Winner of the Circular Game
The classic Josephus problem. I casually Googled one: Josephus Ring - Formula Method.
1 | class Solution { |
Time complexity: O(N),
space complexity: O(1).
1824. Minimum Sideway Jumps
Dynamic Programming.
dp[i][j] means the minimum number of side jumps needed from position i, lane j, to the end.
One thing to note: in this problem N <= 5 * 10^5, so Python top-down DP will blow the stack.
Therefore, during the contest I had one Runtime Error. Adding sys.setrecursionlimit(110000) still did not work, so I changed it to bottom-up DP.
1 | class Solution: |
Time complexity: O(N),
space complexity: O(1).