mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 07:35:35 +08:00
更新 0704.二分查找 排版格式
This commit is contained in:
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
## 算法公开课
|
## 算法公开课
|
||||||
|
|
||||||
***[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[手把手带你撕出正确的二分法](https://www.bilibili.com/video/BV1fA4y1o715),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
|
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[手把手带你撕出正确的二分法](https://www.bilibili.com/video/BV1fA4y1o715),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
|
||||||
|
|
||||||
|
|
||||||
## 思路
|
## 思路
|
||||||
@ -160,7 +160,7 @@ public:
|
|||||||
|
|
||||||
## 其他语言版本
|
## 其他语言版本
|
||||||
|
|
||||||
**Java:**
|
### **Java:**
|
||||||
|
|
||||||
(版本一)左闭右闭区间
|
(版本一)左闭右闭区间
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ class Solution {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Python:**
|
### **Python:**
|
||||||
|
|
||||||
(版本一)左闭右闭区间
|
(版本一)左闭右闭区间
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ class Solution:
|
|||||||
return -1 # 未找到目标值
|
return -1 # 未找到目标值
|
||||||
```
|
```
|
||||||
|
|
||||||
**Go:**
|
### **Go:**
|
||||||
|
|
||||||
(版本一)左闭右闭区间
|
(版本一)左闭右闭区间
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ func search(nums []int, target int) int {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**JavaScript:**
|
### **JavaScript:**
|
||||||
(版本一)左闭右闭区间 [left, right]
|
(版本一)左闭右闭区间 [left, right]
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@ -345,7 +345,7 @@ var search = function(nums, target) {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
**TypeScript**
|
### **TypeScript**
|
||||||
|
|
||||||
(版本一)左闭右闭区间
|
(版本一)左闭右闭区间
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ function search(nums: number[], target: number): number {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
**Ruby:**
|
### **Ruby:**
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
# (版本一)左闭右闭区间
|
# (版本一)左闭右闭区间
|
||||||
@ -425,7 +425,7 @@ def search(nums, target)
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
**Swift:**
|
### **Swift:**
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
// (版本一)左闭右闭区间
|
// (版本一)左闭右闭区间
|
||||||
@ -479,7 +479,7 @@ func search(nums: [Int], target: Int) -> Int {
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Rust:**
|
### **Rust:**
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
# (版本一)左闭右闭区间
|
# (版本一)左闭右闭区间
|
||||||
@ -523,7 +523,8 @@ impl Solution {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**C:**
|
### **C:**
|
||||||
|
|
||||||
```c
|
```c
|
||||||
// (版本一) 左闭右闭区间 [left, right]
|
// (版本一) 左闭右闭区间 [left, right]
|
||||||
int search(int* nums, int numsSize, int target){
|
int search(int* nums, int numsSize, int target){
|
||||||
@ -575,7 +576,8 @@ int search(int* nums, int numsSize, int target){
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**PHP:**
|
### **PHP:**
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// 左闭右闭区间
|
// 左闭右闭区间
|
||||||
class Solution {
|
class Solution {
|
||||||
@ -607,7 +609,8 @@ class Solution {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**C#:**
|
### **C#:**
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
//左闭右闭
|
//左闭右闭
|
||||||
public class Solution {
|
public class Solution {
|
||||||
@ -652,7 +655,8 @@ public class Solution{
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Kotlin:**
|
### **Kotlin:**
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
class Solution {
|
class Solution {
|
||||||
fun search(nums: IntArray, target: Int): Int {
|
fun search(nums: IntArray, target: Int): Int {
|
||||||
@ -682,9 +686,8 @@ class Solution {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### **Kotlin:**
|
||||||
|
|
||||||
|
|
||||||
**Kotlin:**
|
|
||||||
```Kotlin
|
```Kotlin
|
||||||
// (版本一)左闭右开区间
|
// (版本一)左闭右开区间
|
||||||
class Solution {
|
class Solution {
|
||||||
@ -715,7 +718,7 @@ class Solution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
**Scala:**
|
### **Scala:**
|
||||||
|
|
||||||
(版本一)左闭右闭区间
|
(版本一)左闭右闭区间
|
||||||
```scala
|
```scala
|
||||||
@ -763,3 +766,4 @@ object 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>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user