Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add for/while #64

Open
wants to merge 3 commits into
base: merge
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
for/while
  • Loading branch information
ugnjhjf committed Oct 22, 2023
commit 03433e0deaafbe7daa97222986a235176b601f49
4 changes: 4 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ package-lock.json
### 💩 递归总比循环好

如果能使用递归解决问题,就不要使用for while等循环。

_Good 👍🏻_

```javascript
int binarySearchRecur(int []a,int target,int low,int high) {
if (low > high) return -1;
Expand All @@ -406,7 +408,9 @@ int binarySearchRecur(int []a,int target,int low,int high) {
return (target < a[mid])? binarySearchRecur(a, target, low, mid - 1) :binarySearchRecur(a, target, mid + 1, high);
}
```

_Bad 👎🏻_

```javascript
int binarySearch(int []a,int target) {
int l = 0, h = a.length - 1;
Expand Down