You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This Question Includes Both Binary Search And bit of Greedy Concept also.
2
-
// See We Know Ans Always Lies Between 0 and maximum element according to given question condition Because
3
+
// See We Know Ans Always Lies Between 0 and maximum element according to given question condition Because
3
4
// sum value at maximum element is same as any other element greater than it.
4
-
// So we get our sum from getval function after that you need to choose as to move forward(l = mid+1) or backward
5
+
// So we get our sum from getval function after that you need to choose as to move forward(l = mid+1) or backward
5
6
// i.e.(h = mid-1) so if sum value we obtain is less than target then l = mid+1 why so??
6
-
// Because 2 3 5 lets suppose you are having this array if we pick 2 as mid then sum value will be 6 whereas if we pick 3 then sum value will be 8 and 10 when we pick 5 so notice that sum will increase when we increase value and
7
+
// Because 2 3 5 lets suppose you are having this array if we pick 2 as mid then sum value will be 6 whereas if we pick 3 then sum value will be 8 and 10 when we pick 5 so notice that sum will increase when we increase value and
7
8
// correspondingly decrease when we decrease value...So yess This is all what we did and got Accepted.
0 commit comments