Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Find First and Last Position of Element in Sorted Array
Bookmark
Linear Scan
Two Binary Searches
Input
Target in middle
Target not found
Single occurrence
All same
Custom
nums
=
[5, 7, 7, 8, 8, 10]
,
target
=
8
target = 8
0
1
2
3
4
5
5
7
7
8
8
10
target = 8
0
1
2
3
4
5
5
7
7
8
8
10
target = 8
0
1
2
3
4
5
5
7
7
8
8
10
target = 8
0
1
2
3
4
5
5
7
7
8
8
10
i
target = 8
0
1
2
3
4
5
5
7
7
8
8
10
i
target = 8
0
1
2
3
4
5
5
7
7
8
8
10
i
target = 8
0
1
2
3
4
5
5
7
7
8
8
10
i
target = 8
0
1
2
3
4
5
5
7
7
8
8
10
j
target = 8
0
1
2
3
4
5
5
7
7
8
8
10
j
target = 8
0
1
2
3
4
5
5
7
7
8
8
10
j
target = 8
0
1
2
3
4
5
5
7
7
8
8
10
first
last
algo
master
.
io
Step:
Start: find the first and last position of target 8
0 / 10
Input
Target in middle
Target not found
Single occurrence
All same
Custom
nums
=
[5, 7, 7, 8, 8, 10]
,
target
=
8
0 / 10
algo
master
.
io
Step:
Start: find the first and last position of target 8