LeetCode Biweekly Contest 37
| Rank | Name | Score | Finish Time | Q1 (3) | Q2 (4) | Q3 (5) | Q4 (7) |
|---|---|---|---|---|---|---|---|
| 893 / 8250 | YoungForest | 7 | 0:27:31 | 0:11:24 | 0:27:31 | null | null |
I have crashed in two consecutive biweekly contests.
The third problem passed two minutes after the contest ended. It was originally within my ability, but I got too anxious near the end. My state was not good at night in the first place, and ironically I wrote it right after the contest was over.
1619. Mean of Array After Removing Some Elements
A warm-up problem. Sort first, then sum, then take the average.
One thing to note is that the constraints guarantee arr.size() % 20 == 0.
1 | class Solution { |
Time complexity: O(N log N),
space complexity: O(1).
1620. Coordinate With Maximum Network Quality
The constraints are small, only 50, so direct brute force works. Enumerate every position, then enumerate every tower to calculate its signal.
1 | class Solution { |
Time complexity: O(rows * cols * towers),
space complexity: O(1).
1621. Number of Sets of K Non-Overlapping Line Segments
Dynamic Programming. I could immediately tell it was a DP problem, but still took a detour. At first I wrote an O(n^2 * k) algorithm and did not make full use of the subproblems.
In fact, adding one more variable to indicate whether the beginning must be a segment makes it much easier to write.
1 | class Solution: |
Time complexity: O(n * k),
space complexity: O(n * k).
1622. Fancy Sequence
This problem is already beyond my current ability. I had no idea at all.
After studying the discussion section once, it seems there are roughly two types of algorithms: