LeetCode biweekly contest 19
| Rank | Name | Score | Finish Time | Q1 (3) | Q2 (4) | Q3 (5) | Q4 (6) |
|---|---|---|---|---|---|---|---|
| 179 / 3745 | YoungForest | 18 | 0:41:10 | 0:02:39 | 0:10:36 | 0:12:53 | 0:36:10 1 |
This was my first biweekly contest after returning to China. My hands were a bit rusty, and my form was still recovering. Recently, because of the novel coronavirus epidemic, I have been isolating at home and almost cannot go out except to buy groceries. The New Year atmosphere disappeared this year because of it. Staying at home almost made me go stir-crazy. The contest result was okay. Speed contests have also always been a type I am not good at.
1342. Number of Steps to Reduce a Number to Zero
A warm-up problem. Just simulate the two operations: divide by 2 and subtract one.
Time complexity: O(log N),
space complexity: O(1).
1 | class Solution { |
1343. Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold
A simple sliding window. We can directly apply the template.
Time complexity: O(N),
space complexity: O(1).
1 | class Solution { |
1344. Angle Between Hands of a Clock
Compute the angle between the hour hand and the minute hand on a clock. Calculate their positions separately, then compute the included angle.
Time complexity: O(1),
space complexity: O(1).
1 | class Solution { |
1345. Jump Game IV
Another Jump Game problem. I originally thought it would use DP like the previous ones. After one attempt, I found that it actually needed BFS.
One thing to note is that after using the reverse array each time, we need to clear the array so that duplicated computation will not happen. Thanks to hiepit’s post.
Time complexity: O(N),
space complexity: O(N).
1 | class Solution { |