mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2026-03-13 10:02:05 +08:00
Add toc
This commit is contained in:
@@ -80,7 +80,7 @@ disablePathToLower = true
|
||||
# (Optional, default true) Controls table of contents visibility on right side of pages.
|
||||
# Start and end levels can be controlled with markup.tableOfContents setting.
|
||||
# You can also specify this parameter per page in front matter.
|
||||
BookToC = false
|
||||
BookToC = true
|
||||
|
||||
# (Optional, default none) Set the path to a logo for the book. If the logo is
|
||||
# /static/logo.png then the path would be logo.png
|
||||
|
||||
@@ -27,14 +27,13 @@ weight: 3
|
||||
|8|10^9|O(sqrt(n))|筛素数、求平方根|
|
||||
|9|10^10|O(log n)|二分搜索|
|
||||
|10|+∞|O(1)|数学相关算法|
|
||||
|----------------|----------------|------------------------------------------------------------------|--------------------------------|
|
||||
|------------------------------|------------------------------|------------------------------------------------------------------|------------------------------------------------------------------|
|
||||
|
||||
|
||||
一些具有迷惑性的例子:
|
||||
|
||||
```c
|
||||
void hello (int n){
|
||||
|
||||
for( int sz = 1 ; sz < n ; sz += sz)
|
||||
for( int i = 1 ; i < n ; i ++)
|
||||
cout << "Hello" << endl;
|
||||
@@ -45,7 +44,6 @@ void hello (int n){
|
||||
|
||||
```c
|
||||
bool isPrime (int n){
|
||||
|
||||
for( int x = 2 ; x * x <= n ; x ++ )
|
||||
if( n % x == 0)
|
||||
return false;
|
||||
@@ -90,7 +88,7 @@ int sum( int n ){
|
||||
|
||||
## 三. 递归的时间复杂度
|
||||
|
||||
### 只有一次递归调用
|
||||
### 1. 只有一次递归调用
|
||||
|
||||
如果递归函数中,只进行了一次递归调用,且递归深度为 depth,在每个递归函数中,时间复杂度为 T,那么总体的时间复杂度为 O(T * depth)
|
||||
|
||||
@@ -114,7 +112,7 @@ int binarySearch(int arr[], int l, int r, int target){
|
||||
在二分查找的递归实现中,只递归调用了自身。递归深度是 log n ,每次递归里面的复杂度是 O(1) 的,所以二分查找的递归实现的时间复杂度为 O(log n) 的。
|
||||
|
||||
|
||||
### 只有多次递归调用
|
||||
### 2. 只有多次递归调用
|
||||
|
||||
针对多次递归调用的情况,就需要看它的计算调用的次数了。通常可以画一颗递归树来看。举例:
|
||||
|
||||
|
||||
@@ -373,13 +373,13 @@ Range Sum Query 问题专门处理查询范围内的元素总和。这个问题
|
||||
|
||||
|
||||
|
||||
### 2. 单点更新:
|
||||
### 2. 单点更新
|
||||
- [HDU 1166 敌兵布阵](http://acm.hdu.edu.cn/showproblem.php?pid=1166) update:单点增减 query:区间求和
|
||||
- [HDU 1754 I Hate It](http://acm.hdu.edu.cn/showproblem.php?pid=1754) update:单点替换 query:区间最值
|
||||
- [HDU 1394 Minimum Inversion Number](http://acm.hdu.edu.cn/showproblem.php?pid=1394) update:单点增减 query:区间求和
|
||||
- [HDU 2795 Billboard](http://acm.hdu.edu.cn/showproblem.php?pid=2795) query:区间求最大值的位子(直接把update的操作在query里做了)
|
||||
|
||||
### 3. 区间更新:
|
||||
### 3. 区间更新
|
||||
|
||||
- [HDU 1698 Just a Hook](http://acm.hdu.edu.cn/showproblem.php?pid=1698) update:成段替换 (由于只query一次总区间,所以可以直接输出 1 结点的信息)
|
||||
- [POJ 3468 A Simple Problem with Integers](http://poj.org/problem?id=3468) update:成段增减 query:区间求和
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
{"Target":"book.min.d72be39bb6c9e3940e62a4157008da6c9fb4e80dda8e9b692cbdab037c033a5a.css","MediaType":"text/css","Data":{"Integrity":"sha256-1yvjm7bJ45QOYqQVcAjabJ+06A3ajptpLL2rA3wDOlo="}}
|
||||
{"Target":"book.min.fcdb1f07040371dc4d234f40698d15b7fb50f2dc9982bcd0898d9806ff4e07f8.css","MediaType":"text/css","Data":{"Integrity":"sha256-/NsfBwQDcdxNI09AaY0Vt/tQ8tyZgrzQiY2YBv9OB/g="}}
|
||||
@@ -214,7 +214,7 @@ ul.pagination {
|
||||
}
|
||||
|
||||
.book-toc {
|
||||
flex: 0 0 $toc-width;
|
||||
// flex: 0 0 $toc-width; // 使 toc 靠右贴边
|
||||
font-size: $font-size-12;
|
||||
|
||||
.book-toc-content {
|
||||
|
||||
Reference in New Issue
Block a user