You thought I was gone?
Well, it's been more than a year since I last blogged, time passed in the blink of an eye, memories to foster, all like a roller coaster.
The same place where I had written my first ever blog, the same old feeling, but still, nothing is the same, the feeling of nostalgia hits me, the lingering excitement beckons me, and that my friend, is called inspiration.
______________________________________________________________________
Coming to the Problem squatting inside my mind rent free.
You should think of an idea that pops up in your mind before moving on to see my approach.
I am not entirely sure about the solution to this problem but I have an idea, that might be correct. Till now I couldn't think of anything that would prove this solution to be wrong, if you have a corner case or something that I am missing then suggestions are always welcome.
MY APPROACH:-
A simple greedy approach where first I sort the arrays, then create the intervals and store them in a list. After that we'll just go through the intervals one by one and for each interval, will try to find an integer in arr2 which lies in the required range, as soon as we find the integer, we somehow mark that now that integer is used up (won't use this integer again) and move to the next interval to repeat the same process again.
Code:-


Comments
Post a Comment