Sam is a greedy businessman who has opened N stores in a city.at various locations.
The locations of stores are stored in 1 2-Dimensional array.the coordinates of ith store are defined as follows:
starting point would be input[0][i] and ending location would be input[1][i].
for example:when i=0,input[0][0]=2 and input [1][0]=5,it means that the 0th store spans from 2 uniits to 5 units.
The greedy businessman wants to set up warehouse =s which can supply goods to these stores.
A warehouse can only be set up at a good location.A location is said to be good location if it is lying in the ranfe of [a,b],where a denotes the starting unit of a store and b denotes the end unit of any store S(a,b).
for example: a location ‘X’ is a good location with respect to the store (a,b) ifa<==X<=b.
Note:there can be more than one stores located at a particular.
Ex1:
i/p1:2
i/p2:{{1,2},{3,5}}
o/p:1
Ex2:
i/p1:3
i/p2:{{2,5,9},{3,7,10}}
o/p:3
Comments
Leave a comment