Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Tag : 「贪心」
代码:
```Java
class Solution {
static
public String maximumTime(String time) {
StringBuilder sb = new StringBuilder();
sb.append(time.charAt(0) == '?' ? (time.charAt(1) == '?' || time.charAt(1) < '4') ? '2' : '1' : time.charAt(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class Solution {

在朴素的「树状数组」解法中,我们无法直接查询 $[l, r]$ 区间中被覆盖过的个数的根本原因是「某个值可能会被重复添加到树状数组中」。

因此,一种更加优秀的做法:**在往树状数组中添树的时候进行去重,然后通过 $cnt = query(r) - query(l - 1)$ 直接得出 $[l, r]$ 范围内有多少个数被添加过。**
因此,一种更加优秀的做法:**在往树状数组中添数的时候进行去重,然后通过 $cnt = query(r) - query(l - 1)$ 直接得出 $[l, r]$ 范围内有多少个数被添加过。**

这样的 `Set` 去重操作可以使得我们查询的复杂度从 $O(n\log{C})$ 下降到 $O(\log{C})$。

Expand Down