LeetCode weekly contest 216
| Rank | Name | Score | Finish Time | Q1 (3) | Q2 (4) | Q3 (5) | Q4 (6) |
|---|---|---|---|---|---|---|---|
| 862 / 9573 | YoungForest | 18 | 0:58:34 | 0:12:47 | 0:23:33 | 0:33:14 | 0:58:34 |
Previously I had been exempt from checking in with the Cruel Problem Solving group for five consecutive weeks, which felt great for a whole month. Last week, although I ranked within the top 500, I only solved three problems. This week I solved four problems, but fell outside the top 500. Now I have to check in for another week. My ranking in the Cruel group also dropped to 38, no longer the peak days of rank 15.
Since full-time recruiting ended, and because my internship and thesis have been especially busy, I have had no time to practice problems. Even during the busiest period before submitting my thesis format review, I did not solve a single problem. Since November, I have resumed the habit of doing the daily problem on both the Chinese and US LeetCode sites. Mainly because these two problems are usually relatively easy and take little time. Another reason is that I want to check in and earn points, trying to exchange for two sets of clothes before graduation.
The difficulty of the three check-in problems is roughly: Cruel > Chinese site >= US site.
1662. Check If Two String Arrays are Equivalent
A warm-up problem. Concatenate the list of strings and then compare.
1 | class Solution { |
Time complexity: O(sum(word1[i].length) + sum(word2[i].length)),
Space complexity: O(sum(word1[i].length) + sum(word2[i].length)).
1663. Smallest String With A Given Numeric Value
Greedy. Increase the last character as much as possible each time.
1 | class Solution { |
Time complexity: O(N),
Space complexity: O(N).
1664. Ways to Make a Fair Array
Use prefix even sums and prefix odd sums, similar to prefix sum arrays. Also use suffix even sums and suffix odd sums.
Then we can quickly calculate the sum of odd-indexed elements and even-indexed elements after deleting a certain position.
1 | class Solution { |
Time complexity: O(N),
Space complexity: O(N).
1665. Minimum Initial Energy to Finish Tasks
See LingShen’s post.
During the contest, I used an incorrect greedy approach and still passed: find the minimum difference |minimum_i - actual_i| as the remaining value, then compare this value with the largest minimum_i.
The correct solution is really too hard for a 6-point problem. It should be 7 or 8 points. Many people, even if they guessed the right idea, could not prove its correctness.
1 |
|
Time complexity: O(N log N),
Space complexity: O(1).