diff --git a/problems/0189.旋转数组.md b/problems/0189.旋转数组.md
index 35819694..d60612e9 100644
--- a/problems/0189.旋转数组.md
+++ b/problems/0189.旋转数组.md
@@ -33,7 +33,7 @@
向右旋转 2 步: [3,99,-1,-100]。
-# 思路
+## 思路
这道题目在字符串里其实很常见,我把字符串反转相关的题目列一下:
@@ -83,9 +83,9 @@ public:
```
-# 其他语言版本
+## 其他语言版本
-## Java
+### Java
```java
class Solution {
@@ -106,7 +106,7 @@ class Solution {
}
```
-## Python
+### Python
方法一:局部翻转 + 整体翻转
```python
@@ -139,7 +139,7 @@ class Solution:
# 备注:这个方法会导致空间复杂度变成 O(n) 因为我们要创建一个 copy 数组。但是不失为一种思路。
```
-## Go
+### Go
```go
func rotate(nums []int, k int) {
@@ -157,7 +157,7 @@ func reverse(nums []int){
}
```
-## JavaScript
+### JavaScript
```js
var rotate = function (nums, k) {
@@ -178,7 +178,7 @@ var rotate = function (nums, k) {
};
```
-## TypeScript
+### TypeScript
```typescript
function rotate(nums: number[], k: number): void {
@@ -205,3 +205,4 @@ function reverseByRange(nums: number[], left: number, right: number): void {
+
diff --git a/problems/0283.移动零.md b/problems/0283.移动零.md
index 22d6428c..ee3f4291 100644
--- a/problems/0283.移动零.md
+++ b/problems/0283.移动零.md
@@ -3,10 +3,7 @@
参与本项目,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!
-
-# 动态规划:一样的套路,再求一次完全平方数
-
-# 283. 移动零
+# 283. 移动零:动态规划:一样的套路,再求一次完全平方数
[力扣题目链接](https://leetcode.cn/problems/move-zeroes/)
@@ -22,7 +19,7 @@
尽量减少操作次数。
-# 思路
+## 思路
做这道题目之前,大家可以做一做[27.移除元素](https://programmercarl.com/0027.移除元素.html)
@@ -58,9 +55,9 @@ public:
};
```
-# 其他语言版本
+## 其他语言版本
-Java:
+### Java:
```java
public void moveZeroes(int[] nums) {
@@ -77,7 +74,7 @@ public void moveZeroes(int[] nums) {
}
```
-Python:
+### Python:
```python
def moveZeroes(self, nums: List[int]) -> None:
@@ -100,7 +97,7 @@ Python:
fast += 1
```
-Go:
+### Go:
```go
func moveZeroes(nums []int) {
@@ -116,7 +113,8 @@ func moveZeroes(nums []int) {
}
```
-JavaScript:
+### JavaScript:
+
```javascript
var moveZeroes = function(nums) {
let slow = 0;
@@ -133,7 +131,7 @@ var moveZeroes = function(nums) {
};
```
-TypeScript:
+### TypeScript:
```typescript
function moveZeroes(nums: number[]): void {
@@ -159,3 +157,4 @@ function moveZeroes(nums: number[]): void {
+
diff --git a/problems/0922.按奇偶排序数组II.md b/problems/0922.按奇偶排序数组II.md
index c4654f16..72be8fa7 100644
--- a/problems/0922.按奇偶排序数组II.md
+++ b/problems/0922.按奇偶排序数组II.md
@@ -147,8 +147,6 @@ class Solution {
}
```
-### java
-
```java
//方法一:采用额外的数组空间
class Solution {
@@ -384,3 +382,4 @@ function sortArrayByParityII(nums: number[]): number[] {
+
diff --git a/problems/0941.有效的山脉数组.md b/problems/0941.有效的山脉数组.md
index f43a2108..48c29eb4 100644
--- a/problems/0941.有效的山脉数组.md
+++ b/problems/0941.有效的山脉数组.md
@@ -33,7 +33,7 @@
* 输出:true
-# 思路
+## 思路
判断是山峰,主要就是要严格的保存左边到中间,和右边到中间是递增的。
@@ -71,9 +71,9 @@ public:
如果想系统学一学双指针的话, 可以看一下这篇[双指针法:总结篇!](https://programmercarl.com/双指针总结.html)
-# 其他语言版本
+## 其他语言版本
-## Java
+### Java
```java
class Solution {
@@ -101,7 +101,7 @@ class Solution {
}
```
-## Python3
+### Python3
```python
class Solution:
@@ -118,7 +118,7 @@ class Solution:
```
-## Go
+### Go
```go
func validMountainArray(arr []int) bool {
@@ -142,7 +142,7 @@ func validMountainArray(arr []int) bool {
}
```
-## JavaScript
+### JavaScript
```js
var validMountainArray = function(arr) {
@@ -157,7 +157,7 @@ var validMountainArray = function(arr) {
};
```
-## TypeScript
+### TypeScript
```typescript
function validMountainArray(arr: number[]): boolean {
@@ -177,7 +177,7 @@ function validMountainArray(arr: number[]): boolean {
};
```
-## C#
+### C#
```csharp
public class Solution {
@@ -201,3 +201,4 @@ public class Solution {
+
diff --git a/problems/1207.独一无二的出现次数.md b/problems/1207.独一无二的出现次数.md
index 1a7a0019..83ebbcb7 100644
--- a/problems/1207.独一无二的出现次数.md
+++ b/problems/1207.独一无二的出现次数.md
@@ -31,7 +31,7 @@
* -1000 <= arr[i] <= 1000
-# 思路
+## 思路
这道题目数组在是哈希法中的经典应用,如果对数组在哈希法中的使用还不熟悉的同学可以看这两篇:[数组在哈希法中的应用](https://programmercarl.com/0242.有效的字母异位词.html)和[哈希法:383. 赎金信](https://programmercarl.com/0383.赎金信.html)
@@ -71,9 +71,9 @@ public:
};
```
-# 其他语言版本
+## 其他语言版本
-Java:
+### Java:
```java
class Solution {
@@ -97,7 +97,8 @@ class Solution {
}
```
-Python:
+### Python:
+
```python
# 方法 1: 数组在哈西法的应用
class Solution:
@@ -133,10 +134,8 @@ class Solution:
```
+### JavaScript:
-Go:
-
-JavaScript:
``` javascript
// 方法一:使用数组记录元素出现次数
var uniqueOccurrences = function(arr) {
@@ -171,7 +170,7 @@ var uniqueOccurrences = function(arr) {
};
```
-TypeScript:
+### TypeScript:
> 借用数组:
@@ -209,3 +208,4 @@ function uniqueOccurrences(arr: number[]): boolean {
+
diff --git a/problems/1365.有多少小于当前数字的数字.md b/problems/1365.有多少小于当前数字的数字.md
index 7c268769..c706ba21 100644
--- a/problems/1365.有多少小于当前数字的数字.md
+++ b/problems/1365.有多少小于当前数字的数字.md
@@ -39,7 +39,7 @@
* 2 <= nums.length <= 500
* 0 <= nums[i] <= 100
-# 思路
+## 思路
两层for循环暴力查找,时间复杂度明显为$O(n^2)$。
@@ -113,9 +113,9 @@ public:
可以排序之后加哈希,时间复杂度为$O(n\log n)$
-# 其他语言版本
+## 其他语言版本
-Java:
+### Java:
```Java
public int[] smallerNumbersThanCurrent(int[] nums) {
@@ -136,7 +136,8 @@ public int[] smallerNumbersThanCurrent(int[] nums) {
}
```
-Python:
+### Python:
+
```python
class Solution:
def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]:
@@ -151,7 +152,8 @@ class Solution:
return res
```
-Go:
+### Go:
+
```go
func smallerNumbersThanCurrent(nums []int) []int {
// map,key[数组中出现的数] value[比这个数小的个数]
@@ -180,7 +182,8 @@ func smallerNumbersThanCurrent(nums []int) []int {
}
```
-JavaScript:
+### JavaScript:
+
```javascript
// 方法一:使用哈希表记录位置
var smallerNumbersThanCurrent = function(nums) {
@@ -217,7 +220,7 @@ var smallerNumbersThanCurrent = function(nums) {
};
```
-TypeScript:
+### TypeScript:
> 暴力法: