LeetCode weekly contest 130
YoungForest · https://youngforest.github.io/en/2019/03/31/LeetCode-weekly-contest-130/
On this page · 5 sections
| Rank | Name | Score | Finish Time | Q1 (4) | Q2 (5) | Q3 (5) | Q4 (5) |
|---|---|---|---|---|---|---|---|
| 258 / 5236 | YoungForest | 19 | 0:57:19 | 0:06:23 | 0:25:41 | 0:36:25 | 0:52:19(1) |
This contest was relatively easy. All four problems were routine, and without a Hard problem to separate the field, it came down to implementation speed. You had to finish within 50 minutes to get into the top 200.
I lost some time on the second problem, and for the last problem my first idea was muddled, so I took a bit of a detour.
1029. Binary Prefix Divisible By 5
Intuition:
Straightforward. Shift through the bits and check the remainder modulo 5. Pay attention to taking current modulo, because A can be very long.
Time complexity: O(N),
space complexity: O(N).
1 | class Solution { |
1028. Convert to Base -2
Intuition:
Analogous to the base-2 solution. Keep dividing by 2.
1 | class Solution { |
1030. Next Greater Node In Linked List
Intuition:
Monotonic stack.
Time complexity: O(N),
space complexity: O(N).
1 | /** |
1031. Number of Enclaves
Intuition:
DFS. Start the search from the boundary.
Time complexity: O(N^2),
space complexity: O(N^2).
1 | class Solution { |
Postscript
I have solved 319 / 969 problems on LeetCode, which feels like reaching a certain bottleneck. Right now I am going by acceptance rate, which usually means from easy to hard. The easy problems are already done, and the later ones will become harder and harder. At the beginning I could write one problem in 10 minutes and know the approach as soon as I saw it. Now I need half an hour, and each problem requires a while of thinking.
But this is a good sign. Only by working on problems that are difficult enough, yet still within my current ability, can I improve quickly.
Keep going, Forest!