First and last occurrences of x | EASIEST Python solution Geeksforgeeks interview coding

preview_player
Показать описание
Given a sorted array arr containing n elements with possibly, duplicates are to find indexes of first elements, the task is to find the first and last occurrences of an element x in the given array.
Note: If the number x is not found in the array then return both the indices as -1
Рекомендации по теме
Комментарии
Автор

its marked as medium because u have to do it using binary search which would take time complexity of O(logn) whereas this solution would take O(n)

ashutosh-patil
join shbcf.ru