vishwaraj.anand00
BAN USER
Say point records are as {X,Y}.
1. We sort all Xi's and all Yi's on the number line [Some DS] and maintain entry and exit counts for each such Xi and Yi, all initialized to zeros.
2. For each record {Xi, Yi}, we add 1 in entry count of Xi and add 1 in exit count of Yi.
3. Now for the number line, we have at each interval a count of active number of intersections.
4. The max number of that is the answer. While finding the max, if we track the intervals where we are getting that value, we could also get the range of the required intersection.
RepAlmaRJude, Quality Assurance Engineer at Brocade
I am Alma from Livermore USA, I also enjoy reading – my favourite topics being social history, the development and use ...
Repjunehudson, Associate at Advisory Board Company
I am passionate about fashion and love to explore black magic to take revenge.Being a fashion designer involves more ...
Repjimmybdepuy, Front-end Software Engineer at Arista Networks
Hi, I am Jimmy from los Angeles. I am a painter. I have Knowledge of different types and shades of ...
RepShirleyCWest, Software Engineer at Agilent Technologies
Hello, me Shirley and I from Savage. I am an artist and I love to doing art and I am ...
Repritahmixon, Analyst at ADP
Hi, I am a physiotherapy to help people handle everyday problems. I also assist peoples who have issues caused by ...
Repgarycsroka, Backend Developer at Axiom Sources
Hi I’m Gary, an average 19 year old in a state college who sees life as an adventure.Provide ...
Yes it should work.
- vishwaraj.anand00 February 24, 2014I believe in that case instead of returning {1,10} as answer, it will return {2,3}and{6,8}. Because that is the interval intersected by most number of intervals.