Skip to content

Commit dca9082

Browse files
committed
fix: resolve type error
修复小错误,题解增加简单解释。
1 parent f3b3830 commit dca9082

File tree

5 files changed

+16
-9
lines changed
  • lcof

5 files changed

+16
-9
lines changed

lcof/面试题03. 数组中重复的数字/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
## 题目描述
44
找出数组中重复的数字。
55

6-
76
在一个长度为 n 的数组 nums 里的所有数字都在 0~n-1 的范围内。数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次。请找出数组中任意一个重复的数字。
87

98
**示例 1:**
@@ -21,6 +20,10 @@
2120
```
2221

2322
## 解法
23+
0~n-1 范围内的数,分别还原到对应的位置上,如:数字 2 交换到下标为 2 的位置。
24+
25+
若交换过程中发现重复,则直接返回。
26+
2427
### Python3
2528
```python
2629
class Solution:

lcof/面试题04. 二维数组中的查找/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
- `0 <= m <= 1000`
2929

3030
## 解法
31+
从左下角(或右上角)开始查找即可。
32+
3133
### Python3
3234
```python
3335
class Solution:

lcof/面试题05. 替换空格/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
- `0 <= s 的长度 <= 10000`
1616

1717
## 解法
18+
使用 replace 替换即可。
19+
1820
### Python3
1921
```python
2022
class Solution:

lcof/面试题06. 从尾到头打印链表/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
- `0 <= 链表长度 <= 10000`
1515

1616
## 解法
17+
栈实现。
18+
1719
### Python3
1820
```python
1921
# Definition for singly-linked list.

lcof/面试题43. 1~n整数中1出现的次数/README.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,14 @@
3030
<!-- 这里可写通用的实现逻辑 -->
3131
将 n 拆为两部分:最高位 high 和低位 lows。按 high 是否为 1 分别递归求解结果 f(n)。
3232

33-
举例说明。
33+
以 n=3356 举例说明。
3434

35-
n=3356: high=3,lows=356,base=1000
35+
high=3,lows=356,base=1000。此时 n 可拆分为 `0~999`,`1000~1999`,`2000~2999`,`3000~3356`,其中:
3636

37-
此时数字划分为 0~999,1000~1999,2000~2999,3000~3356,其中:
38-
39-
- 0~999 这个范围内 1 的个数为 f(base-1)
40-
- 1000~1999 这个范围内 1 的个数可分为两部分:千位、其余位。千位都为 1,所以 1 的个数为 base+f(base-1)
41-
- 2000~2999 这个范围内 1 的个数为 f(base-1)
42-
- 3000~3356 这个范围内 1 的个数为 f(lows)
37+
- 0~999 范围内 1 的个数为 f(base-1)
38+
- 1000~1999 范围内 1 的个数可分为两部分:千位、其余位。千位都为 1,所以 1 的个数为 base+f(base-1)
39+
- 2000~2999 范围内 1 的个数为 f(base-1)
40+
- 3000~3356 范围内 1 的个数为 f(lows)
4341

4442
因此,1 的总个数为 `high*f(base-1)+f(lows)+base`
4543

0 commit comments

Comments
 (0)