How to make a function that takes a sorted list of integers and returns index of a given number by using binary search? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to make a function that takes a sorted list of integers and returns index of a given number by using binary search?

for instance, func([1,4,6,3,42,7,80,42]) should return [ 4, 7] which means indexes of 42.

11th Aug 2019, 8:24 AM
Beki Mehari
Beki Mehari - avatar
2 Answers
11th Aug 2019, 8:29 AM
Dlite
Dlite - avatar
0
what if I have 2 similar items. I want the index output to be in a list.
11th Aug 2019, 8:52 AM
Beki Mehari
Beki Mehari - avatar