更新 0209. 长度最小的子数组 排版格式修复

This commit is contained in:
jinbudaily
2023-07-17 15:32:24 +08:00
parent ec101bebb2
commit 76c84efca0

View File

@ -23,14 +23,14 @@
* 1 <= nums.length <= 10^5 * 1 <= nums.length <= 10^5
* 1 <= nums[i] <= 10^5 * 1 <= nums[i] <= 10^5
# 算法公开课 ## 算法公开课
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html)[拿下滑动窗口! | LeetCode 209 长度最小的子数组](https://www.bilibili.com/video/BV1tZ4y1q7XE),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 **[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html)[拿下滑动窗口! | LeetCode 209 长度最小的子数组](https://www.bilibili.com/video/BV1tZ4y1q7XE),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
# 思路 ## 思路
## 暴力解法 ### 暴力解法
这道题目暴力解法当然是 两个for循环然后不断的寻找符合条件的子序列时间复杂度很明显是O(n^2)。 这道题目暴力解法当然是 两个for循环然后不断的寻找符合条件的子序列时间复杂度很明显是O(n^2)。
@ -64,7 +64,7 @@ public:
后面力扣更新了数据,暴力解法已经超时了。 后面力扣更新了数据,暴力解法已经超时了。
## 滑动窗口 ### 滑动窗口
接下来就开始介绍数组操作中另一个重要的方法:**滑动窗口**。 接下来就开始介绍数组操作中另一个重要的方法:**滑动窗口**。
@ -151,8 +151,8 @@ public:
## 其他语言版本 ## 其他语言版本
### Java
Java
```java ```java
class Solution { class Solution {
@ -173,7 +173,7 @@ class Solution {
} }
``` ```
Python ### Python
```python ```python
版本一滑动窗口法 版本一滑动窗口法
@ -216,7 +216,8 @@ class Solution:
return min_len if min_len != float('inf') else 0 return min_len if min_len != float('inf') else 0
``` ```
Go ### Go
```go ```go
func minSubArrayLen(target int, nums []int) int { func minSubArrayLen(target int, nums []int) int {
i := 0 i := 0
@ -242,8 +243,7 @@ func minSubArrayLen(target int, nums []int) int {
} }
``` ```
### JavaScript:
JavaScript:
```js ```js
var minSubArrayLen = function(target, nums) { var minSubArrayLen = function(target, nums) {
@ -266,7 +266,7 @@ var minSubArrayLen = function(target, nums) {
}; };
``` ```
Typescript ### Typescript
```typescript ```typescript
function minSubArrayLen(target: number, nums: number[]): number { function minSubArrayLen(target: number, nums: number[]): number {
@ -288,7 +288,7 @@ function minSubArrayLen(target: number, nums: number[]): number {
}; };
``` ```
Swift: ### Swift:
```swift ```swift
func minSubArrayLen(_ target: Int, _ nums: [Int]) -> Int { func minSubArrayLen(_ target: Int, _ nums: [Int]) -> Int {
@ -309,7 +309,7 @@ func minSubArrayLen(_ target: Int, _ nums: [Int]) -> Int {
} }
``` ```
Rust: ### Rust:
```rust ```rust
impl Solution { impl Solution {
@ -336,7 +336,8 @@ impl Solution {
} }
``` ```
PHP: ### PHP:
```php ```php
// 双指针 - 滑动窗口 // 双指针 - 滑动窗口
class Solution { class Solution {
@ -365,7 +366,7 @@ class Solution {
} }
``` ```
Ruby: ### Ruby:
```ruby ```ruby
def min_sub_array_len(target, nums) def min_sub_array_len(target, nums)
@ -383,8 +384,9 @@ def min_sub_array_len(target, nums)
end end
``` ```
C: ### C:
暴力解法: 暴力解法:
```c ```c
int minSubArrayLen(int target, int* nums, int numsSize){ int minSubArrayLen(int target, int* nums, int numsSize){
//初始化最小长度为INT_MAX //初始化最小长度为INT_MAX
@ -433,7 +435,8 @@ int minSubArrayLen(int target, int* nums, int numsSize){
} }
``` ```
Kotlin: ### Kotlin:
```kotlin ```kotlin
class Solution { class Solution {
fun minSubArrayLen(target: Int, nums: IntArray): Int { fun minSubArrayLen(target: Int, nums: IntArray): Int {
@ -485,7 +488,7 @@ class Solution {
} }
} }
``` ```
Scala: ### Scala:
滑动窗口: 滑动窗口:
```scala ```scala
@ -533,7 +536,8 @@ object Solution {
} }
} }
``` ```
C#: ### C#:
```csharp ```csharp
public class Solution { public class Solution {
public int MinSubArrayLen(int s, int[] nums) { public int MinSubArrayLen(int s, int[] nums) {
@ -559,3 +563,4 @@ public class Solution {
<a href="https://programmercarl.com/other/kstar.html" target="_blank"> <a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/> <img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a> </a>