Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Latest commit

 

History

History
executable file
·
23 lines (13 loc) · 823 Bytes

Search_For_Range.md

File metadata and controls

executable file
·
23 lines (13 loc) · 823 Bytes

Search For Range

Problem Statement

Search For Range Write a function that takes in a sorted array of integers as well as a target integer. The function should use a variation of the Binary Search algorithm to nd a range of indices in between which the target number is contained in the array and should return this range in the form of an array. The rst number in the output array should represent the rst index at which the target number is located while the second number should represent the last index at which the target number is located. The function should return [-1, -1] if the number is not contained in the array.

Sample input: [0, 1, 21, 33, 45, 45, 45, 45, 45, 45, 61, 71, 73], 45 Sample output: [4, 9]

Explanation

Solution

Check this Python code.