MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / searchRange

Method searchRange

FirstAndLastOccuranceOfElement.java:2–14  ·  view source on GitHub ↗
(int[] nums, int target)

Source from the content-addressed store, hash-verified

1class Solution {
2 public int[] searchRange(int[] nums, int target) {
3
4 // define array for storing output
5 int arr[] = new int[2];
6 // initialize with -1
7 Arrays.fill(arr,-1);
8
9 // border case
10 if(nums==null || nums.length==0) return arr;
11 arr[0] = search(nums,target,true);
12 arr[1] = search(nums,target,false);
13 return arr;
14 }
15
16 int search(int nums[],int target, boolean isFirst)
17 {

Callers

nothing calls this directly

Calls 1

searchMethod · 0.95

Tested by

no test coverage detected