Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 626 Bytes

File metadata and controls

26 lines (22 loc) · 626 Bytes

First And Last Occurence of X

Easy


  1. You are given a number n, representing the size of array a.
  2. You are given n numbers, representing elements of array a.
  3. You are given a number k
  4. And You have to find its first occurrence in the array as well as its last occurrence.
  5. Asssumption- Array is sorted. Array may have duplicate values.

Example 1:

Input:  
n = 15
a[] = {1, 5, 10, 15, 22, 33, 33, 33, 33, 33, 40, 42, 55, 66, 77}
k = 33 
Output:  5 9

Constraints:

1 <= n <= 1000
1 <= n1, n2, .. n elements <= 100
1 <= d <= 100