修改一些小问题

This commit is contained in:
labuladong
2020-03-02 22:53:06 +08:00
parent b69b058332
commit d6825ae448
5 changed files with 5 additions and 4 deletions

View File

@ -1,7 +1,8 @@
# Remove Duplicates from Sorted Array
Translator:[Hi_archer][1]
Author:[labuladong][2]
Translator: [Hi_archer][1]
Author: [labuladong][2]
We know that for arrays,it is efficient to insert and delete elements at the end,with a time complexity of O(1).However, if we insert and delete elements at the middle or the beginning,it will move many data, with a time complexity of O(N).

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -157,7 +157,7 @@ int left_bound(int[] nums,int target){
>A2: Before this, let's think about what's meaning of `left border` is:
![](../pictures/%E4%BA%8C%E5%88%86%E6%9F%A5%E6%89%BE/binarySearch1.png)
![](../pictures/binarySearch/binarySearch1.png)
For this array, the algorithm will get result `1`. The result `1` can be interpreted this way: there is 1 element in `nums` which element is less than 2.
@ -243,7 +243,7 @@ int right_bound(int[] nums,int target){
//Thinking this way: mid = left - 1
}
```
![](../pictures/%E4%BA%8C%E5%88%86%E6%9F%A5%E6%89%BE/binarySearch2.png)
![](../pictures/binarySearch/binarySearch2.png)
When we update the value of `left`, we must do it this way: `left = mid + 1`, which means when `while` is terminated, `nums[left]` must not equal to `target`, but `nums[left-1]` could be equal to `target`.

Binary file not shown.