Skip to content

Commit

Permalink
Day18-q2 solution added in python SnowScriptWinterOfCode#409
Browse files Browse the repository at this point in the history
  • Loading branch information
Tech-neophyte authored Jan 17, 2024
1 parent 3f2cd02 commit 34f30bf
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Day-18/q2: Search in Rotated Sorted Array/Tech-neophyte--p.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Python code:
```
class Solution {
public int search(int[] A, int B) {
int l = 0;
int r = A.length-1;
int m;
while(l<=r){
m = (l+r)/2;
if(A[m] == B) return m;
if(A[m]>=A[0]){
if(B>=A[0] && B<=A[m]) r = m-1;
else l = m+1;
}else{
if(B>=A[m] && B<=A[A.length-1]) l = m+1;
else r = m-1;
}
}
return -1;
}
}
```

0 comments on commit 34f30bf

Please sign in to comment.