Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 55723b7

Browse filesBrowse files
committed
add analysis for day 1
1 parent 1f1201b commit 55723b7
Copy full SHA for 55723b7

File tree

Expand file treeCollapse file tree

3 files changed

+36
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+36
-0
lines changed

‎May-LeetCoding-Challenge/.DS_Store

Copy file name to clipboard
6 KB
Binary file not shown.
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#### Summary
2+
A direct application of the Binary Search algorithm.
3+
4+
5+
#### Template of Binary Search [Pseudo Code]
6+
```
7+
int binary_search(int[] arr, int target){
8+
int left = ..., right = ... ;
9+
while (...){
10+
int mid = (right - left) / 2 + left;
11+
if (arr[mid] == target){
12+
...
13+
}
14+
else if (arr[mid] < target){
15+
left = ...
16+
}
17+
else if (arr[mid] > target){
18+
right = ...
19+
}
20+
}
21+
return ...
22+
}
23+
```
24+
25+
#### Remarks
26+
27+
* Use
28+
```
29+
mid = (right - left) / 2 + left
30+
```
31+
instead of
32+
```
33+
mid = (left + right) / 2
34+
```
35+
to avoid any overflow in intermediare calculation.
36+
*

‎May-LeetCoding-Challenge/algorithm-description.md

Copy file name to clipboardExpand all lines: May-LeetCoding-Challenge/algorithm-description.md
Whitespace-only changes.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.