Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6c620a8

Browse files
Update 715.range-module.md
1 parent d59fceb commit 6c620a8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎problems/715.range-module.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class RangeModule(object):
8888

8989
但其实这种做法 overlap 的时间复杂度是 $O(N),ドル这部分可以优化。优化点点在于 overlap 的实现,实际上被跟踪的区间是有序的,因此这部分其实也可是二分查找。只不过我写了一半就发现不好根据结束时间查找。
9090

91-
参考了 [这篇题解](https://leetcode.com/problems/range-module/discuss/244194/Python-solution-using-bisect_left-bisect_right-with-explanation "Python solution using bisect_left, bisect_right with explanation") 后发现,其实我们可以将被跟踪的区块一维化处理,这样问题就简单了。比如我们不这样记录被跟踪的区间 [(1,2),(3,6),(8,12)],而是这样:[1,2,3,5,8,12]
91+
参考了 [这篇题解](https://leetcode.com/problems/range-module/discuss/244194/Python-solution-using-bisect_left-bisect_right-with-explanation "Python solution using bisect_left, bisect_right with explanation") 后发现,其实我们可以将被跟踪的区块一维化处理,这样问题就简单了。比如我们不这样记录被跟踪的区间 [(1,2),(3,5),(8,12)],而是这样:[1,2,3,5,8,12]
9292

9393
经过这样的处理, 数组的奇数坐标就是区间的结束点,偶数坐标就是开始点啦。这样二分就不需要像上面一样使用元组,而是使用单值了。
9494

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /