LeetCode Biweekly Contest 23
YoungForest · https://youngforest.github.io/en/2020/04/07/LeetCode-biweekly-contest-23/
On this page · 4 sections
| Rank | Name | Score | Finish Time | Q1 (3) | Q2 (5) | Q3 (5) | Q4 (6) |
|---|---|---|---|---|---|---|---|
| 199 / 7026 | YoungForest | 19 | 0:40:57 | 0:08:05 | 0:11:44 | 0:33:38 | 0:40:57 |
Not difficult; a speed contest. I found that in many speed contests, the third problem is sometimes even harder than the fourth.
1399. Count Largest Group
Straightforward. Use a HashMap to count digit_sum -> count, then find how many groups have the largest count.
Time complexity: O(N),
space complexity: O(N).
1 | class Solution { |
1400. Construct K Palindrome Strings
Count the number of characters that appear an odd number of times; it must be less than or equal to k. Also, since the required palindrome strings must be non-empty, we need s.size() >= k.
Time complexity: O(N),
space complexity: O(1).
1 | class Solution { |
1401. Circle and Rectangle Overlapping
Based on the four sides of the square, divide the space into 9 parts, and classify the circle center into 9 possible positions. For each case, it is easy to determine whether it overlaps with the square.
Time complexity: O(1),
space complexity: O(1).
1 | class Solution { |
There is also a simpler method to implement in the discussion section, which quickly finds the point in the rectangle closest to a given point, the circle center.
1402. Reducing Dishes
Greedy. Sort first, then take the dishes with the largest satisfaction values until the suffix sum becomes less than 0.
Time complexity: O(N log N),
space complexity: O(1).
1 | class Solution { |
My first submission used an N^2 solution: sort and then enumerate the starting point. It actually passed.