Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned long peak(unsigned long nel, int (*less)(unsigned long i, unsigned long j)){
- unsigned long left = 0, right = nel-1, x, ans;
- while (left<right){
- x = left + (right-left)/2;
- if (less(x+1, x)) right = x;
- else left = x+1;
- }
- if(less(right, left)) ans = left;
- else ans = right;
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement