0 like 0 dislike
1,785 views
| 1,785 views

0 like 0 dislike

(Grasp the STL concept in binary search , you should use it whenever you want to make things easy)

Step-2 : Solve these :

33. Search in Rotated Sorted Array

34. Find First and Last Position of Element in Sorted Array

35. Search Insert Position

69. Sqrt(x)

74. Search a 2D Matrix

Step-3 : Hope , you are getting the idea now! Read : https://www.topcoder.com/thrive/articles/Binary%20Search

Step-4 : Solve :

4)Do utmost P operations . In each operation  ,select a subarray of size ‘k’ and add ‘1’s to it . Maximize the minimum element.

7)Partition array into k parts , such that the part with maximum sum is as small as possible.

8)https://codeforces.com/contest/1486/problem/C2

9)https://www.codechef.com/problems/GOTHAM

Now , do these :

https://www.codechef.com/LTIME87A/problems/ALIENIN

https://codeforces.com/contest/1354/problem/C1

https://codeforces.com/contest/1354/problem/C2

Find the longest subarray whose cost is less than “s”.[Binary-Search]

(Cost of a subarray is :----> [i:j]-->[ a[i]+i*k + a[i+1]+(i+1)*k+....],where ‘k’ is length of the subarray)Solution:-https://ideone.com/xcpv66(Yes-code)

https://www.geeksforgeeks.org/largest-subarray-having-sum-greater-than-k/

You are a master now , you know what to do now !!!

by Expert (19,470 points)
0 like 0 dislike

Best Resources for Binary Search :

https://codeforces.com/blog/entry/67509

Best Problems :

Good LeetCode Problems :

3)https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets/

(partition array into k parts , such that the part with maximum sum is minimized , find that maximum sum )

New Problem : https://codeforces.com/contest/1486/problem/C2

-------------------------------------------------------------------------------------------------------------------------

1)

{Double Binary Search}

Solution : Sort the ranges w.r.p to start point one time.

Another time w.r.p to end time.

(Descending Order)

Now you want to know how many numbers are greater than equal to 7.

Say ranges are : [100,90] ,[95,67],[30,7],[10,1],[9,2],[5,1]

[Start,End]

End points : [90,67,7,2,1,1]

Sum of all guys with end-points>=7=>x

(Don’t consider those ranges which start and end at 7 now,because they have been considered above already)

All ranges with start points greater than equal to 7 : [100,90] ,[95,67],[30,7],[10,1],[9,2].

And from them, only those guys with end-points smaller than 7(their sum)  : abs(10-1)+1 + abs(9-2)+1 = 18=y.

Answer is x + y .

{Code Not written}

Similar to :

{Double Binary Search}

(Same logic for the kth smallest pair)

(Yes-Code)

------------------------------------------------------------------------------------------------------------------

1)https://www.codechef.com/problems/ALIEN1(Yes Code)

https://codeforces.com/contest/1354/problem/C1(Geometry+Circles)(No-code)

https://codeforces.com/contest/1354/problem/C2(Geometry+Circles)(No-code)

Find the longest subarray whose cost is less than “s”.[Binary-Search]

(Cost of a subarray is :----> [i:j]-->[ a[i]+i*k + a[i+1]+(i+1)*k+....],where ‘k’ is length of the subarray)Solution:-https://ideone.com/xcpv66(Yes-code)

6)https://codeforces.com/contest/1295/problem/C(Yes-code)

(No-code)

Required : Longest Subarray with Sum greater than Equal to Zero

https://www.geeksforgeeks.org/largest-subarray-having-sum-greater-than-k/

(No-code)

(No-code)

(Yes-code)

16)https://www.hackerearth.com/challenges/competitive/april-circuits-20/algorithm/people-carrying-6dd467ed/editorial/(Later){Great-Problem){No-code}

by Expert (19,470 points)