Skip to content

Commit 68c5900

Browse files
Added solution
1 parent 63dd50c commit 68c5900

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

transition_point.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*This is a function problem.You only need to complete the function given below*/
2+
3+
int helper(int arr[], int strt, int end){
4+
while(strt <= end){
5+
int mid = strt + (end - strt)/2;
6+
if(arr[mid] == 1 && arr[mid - 1] == 0)
7+
return mid;
8+
else if(arr[mid] == 1)
9+
end = mid - 1;
10+
else
11+
strt = mid + 1;
12+
}
13+
return -1;
14+
}
15+
16+
int transitionPoint(int arr[],int n)
17+
{
18+
// Your code goes here
19+
int strt = 0, end = n -1;
20+
return helper(arr, strt, end);
21+
}

0 commit comments

Comments
 (0)