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 a5eb340

Browse files
更新 图论 并查集 模拟 位运算 额外题目 排版格式修复
1 parent e9b0d46 commit a5eb340

7 files changed

+51
-44
lines changed

‎problems/0031.下一个排列.md‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* 输出:[1]
3535

3636

37-
# 思路
37+
## 思路
3838

3939
一些同学可能手动写排列的顺序,都没有写对,那么写程序的话思路一定是有问题的了,我这里以1234为例子,把全排列都列出来。可以参考一下规律所在:
4040

@@ -92,9 +92,9 @@ public:
9292
};
9393
```
9494
95-
# 其他语言版本
95+
## 其他语言版本
9696
97-
## Java
97+
### Java
9898
9999
```java
100100
class Solution {
@@ -159,7 +159,7 @@ class Solution {
159159
}
160160
```
161161
162-
## Python
162+
### Python
163163
>直接使用sorted()会开辟新的空间并返回一个新的list,故补充一个原地反转函数
164164
```python
165165
class Solution:
@@ -191,7 +191,7 @@ class Solution:
191191
"""
192192
```
193193

194-
## Go
194+
### Go
195195

196196
```go
197197
//卡尔的解法
@@ -216,7 +216,7 @@ func reverse(a []int,begin,end int){
216216
}
217217
```
218218

219-
## JavaScript
219+
### JavaScript
220220

221221
```js
222222
//卡尔的解法(吐槽一下JavaScript的sort和其他语言的不太一样,只想到了拷贝数组去排序再替换原数组来实现nums的[i + 1, nums.length)升序排序)
@@ -272,3 +272,4 @@ var nextPermutation = function(nums) {
272272
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
273273
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
274274
</a>
275+

‎problems/0127.单词接龙.md‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* 解释:endWord "cog" 不在字典中,所以无法进行转换。
3030

3131

32-
# 思路
32+
## 思路
3333

3434
以示例1为例,从这个图中可以看出 hit 到 cog的路线,不止一条,有三条,一条是最短的长度为5,两条长度为6。
3535

@@ -97,9 +97,9 @@ public:
9797

9898
当然本题也可以用双向BFS,就是从头尾两端进行搜索,大家感兴趣,可以自己去实现,这里就不再做详细讲解了。
9999

100-
# 其他语言版本
100+
## 其他语言版本
101101

102-
## Java
102+
### Java
103103

104104
```java
105105
public int ladderLength(String beginWord, String endWord, List<String> wordList) {
@@ -196,7 +196,7 @@ class Solution {
196196
}
197197
```
198198

199-
## Python
199+
### Python
200200

201201
```
202202
class Solution:
@@ -221,7 +221,7 @@ class Solution:
221221
queue.append(newWord)
222222
return 0
223223
```
224-
## Go
224+
### Go
225225
```go
226226
func ladderLength(beginWord string, endWord string, wordList []string) int {
227227
wordMap, que, depth := getWordMap(wordList, beginWord), []string{beginWord}, 0
@@ -274,7 +274,7 @@ func getCandidates(word string) []string {
274274
}
275275
```
276276

277-
## JavaScript
277+
### JavaScript
278278
```javascript
279279
var ladderLength = function(beginWord, endWord, wordList) {
280280
// 将wordList转成Set,提高查询速度
@@ -310,7 +310,7 @@ var ladderLength = function(beginWord, endWord, wordList) {
310310
};
311311
```
312312

313-
## TypeScript
313+
### TypeScript
314314
```typescript
315315
function ladderLength(
316316
beginWord: string,
@@ -364,4 +364,3 @@ function diffonechar(word1: string, word2: string): boolean {
364364
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
365365
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
366366
</a>
367-

‎problems/0463.岛屿的周长.md‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public:
9090

9191
## 其他语言版本
9292

93-
Java:
93+
### Java:
9494

9595
```java
9696
// 解法一
@@ -191,8 +191,8 @@ class Solution {
191191

192192
```
193193

194-
Python:
195-
### 解法1:
194+
### Python:
195+
196196
扫描每个cell,如果当前位置为岛屿 grid[i][j] == 1, 从当前位置判断四边方向,如果边界或者是水域,证明有边界存在,res矩阵的对应cell加一。
197197

198198
```python
@@ -228,7 +228,8 @@ class Solution:
228228

229229
```
230230

231-
Go:
231+
### Go:
232+
232233
```go
233234
func islandPerimeter(grid [][]int) int {
234235
m, n := len(grid), len(grid[0])
@@ -249,7 +250,8 @@ func islandPerimeter(grid [][]int) int {
249250
}
250251
```
251252

252-
JavaScript:
253+
### JavaScript:
254+
253255
```javascript
254256
//解法一
255257
var islandPerimeter = function(grid) {
@@ -305,3 +307,4 @@ var islandPerimeter = function(grid) {
305307
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
306308
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
307309
</a>
310+

‎problems/0657.机器人能否返回原点.md‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131

32-
# 思路
32+
## 思路
3333

3434
这道题目还是挺简单的,大家不要想复杂了,一波哈希法又一波图论算法啥的,哈哈。
3535

@@ -64,9 +64,9 @@ public:
6464
```
6565
6666
67-
# 其他语言版本
67+
## 其他语言版本
6868
69-
## Java
69+
### Java
7070
7171
```java
7272
// 时间复杂度:O(n)
@@ -86,7 +86,7 @@ class Solution {
8686
}
8787
```
8888

89-
## Python
89+
### Python
9090

9191
```python
9292
# 时间复杂度:O(n)
@@ -107,7 +107,7 @@ class Solution:
107107
return x == 0 and y == 0
108108
```
109109

110-
## Go
110+
### Go
111111

112112
```go
113113
func judgeCircle(moves string) bool {
@@ -131,7 +131,7 @@ func judgeCircle(moves string) bool {
131131
}
132132
```
133133

134-
## JavaScript
134+
### JavaScript
135135

136136
```js
137137
// 时间复杂度:O(n)
@@ -150,7 +150,7 @@ var judgeCircle = function(moves) {
150150
```
151151

152152

153-
## TypeScript
153+
### TypeScript
154154

155155
```ts
156156
var judgeCircle = function (moves) {
@@ -185,3 +185,4 @@ var judgeCircle = function (moves) {
185185
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
186186
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
187187
</a>
188+

‎problems/0684.冗余连接.md‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* edges 中无重复元素
2626
* 给定的图是连通的
2727

28-
# 思路
28+
## 思路
2929

3030
这道题目也是并查集基础题目。
3131

@@ -150,9 +150,9 @@ public:
150150
可以看出,主函数的代码很少,就判断一下边的两个节点在不在同一个集合就可以了。
151151

152152

153-
# 其他语言版本
153+
## 其他语言版本
154154

155-
## Java
155+
### Java
156156

157157
```java
158158
class Solution {
@@ -205,7 +205,7 @@ class Solution {
205205
}
206206
```
207207

208-
## Python
208+
### Python
209209

210210
```python
211211

@@ -256,7 +256,7 @@ class Solution:
256256
return []
257257
```
258258

259-
## Go
259+
### Go
260260

261261
```go
262262

@@ -312,7 +312,7 @@ func findRedundantConnection(edges [][]int) []int {
312312
}
313313
```
314314

315-
## JavaScript
315+
### JavaScript
316316

317317
```js
318318
const n = 1005;
@@ -365,3 +365,4 @@ var findRedundantConnection = function(edges) {
365365
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
366366
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
367367
</a>
368+

‎problems/0685.冗余连接II.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ public:
213213
```
214214
215215
216-
# 其他语言版本
216+
## 其他语言版本
217217
218-
## Java
218+
### Java
219219
220220
```java
221221
@@ -335,7 +335,7 @@ class Solution {
335335
}
336336
```
337337

338-
## Python
338+
### Python
339339

340340
```python
341341

@@ -426,7 +426,7 @@ class Solution:
426426
return self.getRemoveEdge(edges)
427427
```
428428

429-
## Go
429+
### Go
430430

431431
```go
432432

@@ -527,7 +527,7 @@ func findRedundantDirectedConnection(edges [][]int) []int {
527527

528528
```
529529

530-
## JavaScript
530+
### JavaScript
531531

532532
```js
533533
const N = 1010; // 如题:二维数组大小的在3到1000范围内
@@ -623,3 +623,4 @@ var findRedundantDirectedConnection = function(edges) {
623623
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
624624
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
625625
</a>
626+

‎problems/1356.根据数字二进制下1的数目排序.md‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747

4848

49-
# 思路
49+
## 思路
5050

5151
这道题其实是考察如何计算一个数的二进制中1的数量。
5252

@@ -87,7 +87,7 @@ int bitCount(int n) {
8787

8888
下面我就使用方法二,来做这道题目:
8989

90-
## C++代码
90+
9191

9292
```C++
9393
class Solution {
@@ -116,9 +116,9 @@ public:
116116
117117
118118
119-
# 其他语言版本
119+
## 其他语言版本
120120
121-
## Java
121+
### Java
122122
123123
```java
124124
class Solution {
@@ -151,7 +151,7 @@ class Solution {
151151

152152

153153

154-
## Python
154+
### Python
155155

156156
```python
157157
class Solution:
@@ -167,7 +167,7 @@ class Solution:
167167
return count
168168
```
169169

170-
## Go
170+
### Go
171171

172172
```go
173173
func sortByBits(arr []int) []int {
@@ -205,7 +205,7 @@ func bitCount(n int) int {
205205
}
206206
```
207207

208-
## JavaScript
208+
### JavaScript
209209

210210
```js
211211
var sortByBits = function(arr) {
@@ -227,3 +227,4 @@ var sortByBits = function(arr) {
227227
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
228228
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
229229
</a>
230+

0 commit comments

Comments
(0)

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