LeetCode weekly contest 236
YoungForest · https://youngforest.github.io/2021/04/11/LeetCode-weekly-contest-236/
文章目录 · 4 节
| 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
签到题。多少负数,是否有0。
1 | class Solution: |
时间复杂度: O(N),
空间复杂度: O(1).
1823. Find the Winner of the Circular Game
经典的约瑟夫环问题。随便Google了一个: 约瑟夫环——公式法。
1 | class Solution { |
时间复杂度: O(N),
空间复杂度: O(1).
1824. Minimum Sideway Jumps
动态规划。
dp[i][j] 表示从i的位置,第j个lane 到末尾需要的最小side jumps.
需要注意的是 本题N <= 5 * 10^5,Python TOP-BOTTOM的DP会爆栈。
因此比赛时Runtime Error一次,加了
sys.setrecursionlimit(110000)仍然不行,遂改成了Bottom-Up 的DP。
1 | class Solution: |
时间复杂度: O(N),
空间复杂度: O(1).