LeetCode Weekly Contest 182
YoungForest · https://youngforest.github.io/en/2020/03/29/LeetCode-weekly-contest-182/
On this page · 4 sections
| Rank | Name | Score | Finish Time | Q1 (3) | Q2 (4) | Q3 (5) | Q4 (8) |
|---|---|---|---|---|---|---|---|
| 727 / 11694 | YoungForest | 12 | 0:22:50 | 0:03:13 | 0:14:04 | 0:22:50 | null |
This Monday I joined a LeetCode daily check-in and weekly contest group. It publishes rankings every week, and the bottom-ranked person sends a red packet; every day there is a designated problem to solve, and if you miss two consecutive days you also send a red packet. It is extremely intense and exciting. Contest leaderboard.
This was my first contest since joining the group. Because the fourth problem was too hard, only around one hundred people solved it in total. In the group, only five people got AC.
1394. Find Lucky Integer in an Array
A warm-up problem. Pay attention to the data range and just count frequency.
Time complexity: O(N),
space complexity: O(N).
1 | class Solution { |
1395. Count Number of Teams
Because the data scale is small, even an N^3 solution that enumerates all triples can pass.
Here I used DP, with N^2 complexity. If using an order statistic tree, it can be further reduced to N log N.
Time complexity: O(N ^ 2),
space complexity: O(N).
1 | class Solution { |
1396. Design Underground System
Straightforward.
Use a map to record the total time and number of people for each pair of stations.
Time complexity:
- checkIn: O(1),
- checkOut: O(1 + log N),
- getAverageTime: O(log N).
Space complexity: O(user.size() + station.size() ^ 2).
1 | class UndergroundSystem { |