int left = range_left - 1, right = range_right + 1;while(right - left > 1) { int mid = (left + right) / 2; if (as[mid] >= val) { right = mid; } else { left = mid }}[12:15 AM]Shaanjeet:for your second point, i wouldnt treat it as < or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->if (as[mid] >= val)< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->I like to treat it this way < or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->if (cond(mid))< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->where cond(i) returns true if the condition is satisfied or not. This type of binary search returns the leftmost element satisfying cond(i)< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:22 AM ] Shaanjeet : condition in your case is as[mid] >= val< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:22 AM ] Shaanjeet : it doesnt matter if you put it as > >=< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:22 AM ] Siddharth Bhat : Right, thanks, that makes a lot of sense.< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:22 AM ] Siddharth Bhat : And as for #1 and #3?< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:23 AM ] Shaanjeet : it depends on implementation. I use my implementation because it always works [< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->12:23 AM ] Siddharth Bhat : Indeed.< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:23 AM ] Shaanjeet :< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->i tried to eleminate the mid + 1 and mid -1 so that i dont have to think during a contest< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:24 AM ] Shaanjeet : im not sure if it is good from theory point of view but in practise it always works for me< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:24 AM ] Shaanjeet :< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->also i prefer to keep the bound always greater by 1, as right = right_range + 1.< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:25 AM ] Shaanjeet : So that i can identify if there is no element that satisfy the condition in my range< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:25 AM ] Shaanjeet : another good thing about my way is that at the end it gives you 2 values. right = leftmost element satisfying the condition and left = rightmost element not satisfying the condition< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:26 AM ] Shaanjeet :< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->so i never have to change it for rightmost or leftmost< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:26 AM ] Shaanjeet : it works almost as a template< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->[ 12:35 AM ] Siddharth Bhat : @Shaanjeet When you say< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -> right = leftmost element satisfying the condition, < or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -> left = rightmost element not satisfying the condition< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part ->Can you tell me what happens when my cond(mid) = as[mid] <= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >= 10?< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >[ 12:38 AM ] Siddharth Bhat :< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >ix: 0 1 2 3 4 5 6 7 8 9< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >cond: F F T T T T T T T T< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >[ 12:39 AM ] Siddharth Bhat : Now where will left and right be? Will it be left=2, right=3?< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >[ 12:39 AM ] Shaanjeet : no< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >[ 12:39 AM ] Shaanjeet : left = 1, right = 2< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >[ 12:40 AM ] Siddharth Bhat : argh yes :smile:< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >[ 12:41 AM ] Shaanjeet :< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > int n;< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > cin >> n;< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > vector arr(n);< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > for (auto &it : arr) {< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > cin >> it;< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > }< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > int left = -1, right = n;< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > while (right - left > 1) {< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > int mid = (left + right) / 2;< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > if (arr[mid] >= 10) {< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > right = mid;< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > } else {< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > left = mid;< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > }< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > }< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid > cout << left << " " << right << "\n";< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >[ 12:41 AM ] Shaanjeet : i used this to find it [< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >[ 12:42 AM ] Siddharth Bhat :< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >And if such an element does not exist, eg. something like:< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >as: [0, 0, 0, 0]< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >ix: 0 1 2 3< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >cond:F F F F< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >I'll have right=4, left=3?< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >[ 12:42 AM ] Shaanjeet : yes< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >[ 12:43 AM ] Shaanjeet : and if it was T T T T then you would get left = -1< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >[ 12:43 AM ] Shaanjeet : and right = 0< or <=. I treat it as if the condition is satisfied or not. Writing this way gives you the leftmost element satisfying the condition
[ 12:19 AM ] Siddharth Bhat : Can you please elaborate on what you mean why you say I treat it as if the condition is satisfied or not
[ 12:20 AM ] Shaanjeet : when you do this part -><= 10, and I search on the array
as: [1, 2, 10, 10, 10, 10, 10, 25, 35, 45
ix: 0 1 2 3 4 5 6 7 8 9
cond: T T T T T T T F F F
using your implementation? Where will left and right be at the end?
Sorry, I found interpreting what you said hard.
[ 12:37 AM ] Shaanjeet : ok i shouldve mentioned that the condition should be of the form F F F F F F F T T T as i assume a increasing sequence
[ 12:37 AM ] Shaanjeet : which is easy to do by negating the cond(mid)
[ 12:38 AM ] Siddharth Bhat : Sure, let me take cond(mid) = mid >[ 12:44 AM ] Siddharth Bhat : neat, thanks.