Whenever your heart is broken Don't ever forget you're golden I will find a light in your soul I'll be there Never leaving you in the darkness Even when you're out of focus I will be the light in your life You'll see clear I'll be your inspiration 'Cause I know that you'll do just what you're told I'll be your hard-earned temptation, yeah 'Cause I know that you'll make it on your own Baby, you can count on me now When you're falling down, down, down I will find a light in your soul I'll be there Leaving you alone is the hardest Even when you're out of focus I will be the light in your life You'll see clear I'll be your inspiration 'Cause I know that you'll do just what you're told I'll be your hard-earned temptation, yeah 'Cause I know that you'll make it on your own I'll be your inspiration 'Cause I know that you'll do just what you're told I'll be your hard-earned temptation, yeah 'Cause I know that you'll make it on your own Yeah, on your own ----------------------------------------------------- yes you are our inspiration striver 🥰
as soon as I listened n meetings in a room I rushed back to questions. I was struggling with my approach but as soon I heard the title n meetings I got the solution .
Yeah I had the same doubt, it can be cleared with an example: Lets say we have [(0,3),(2,4),(3,6)] According to you, if we sort by the length of the intervals, we'll complete (2,4) first - effectively blocking (0,3) and (3,6) Instead if we sort by end times, we'll get (0,3)(3,6) as valid non clashing intervals. Sorting based on length of the intervals doesn't give an optimal substructure.
I sorted the array with respect to start time in ascending order. While traversing, if start_time of the current interval is greater than end time of the previously selected interval, then we would need to remove one interval, and we would remove that interval whose end time is lesser. it works . bool compare(vector& a, vector& b) { if ( a[0] < b[0]) return true; if ( a[0] == b[0]) { return a[1] < b[1]; } return false; } int eraseOverlapIntervals(vector& intervals) { int n = intervals.size(); if ( n == 1) return 0 ; sort(intervals.begin(), intervals.end(), compare); int count = 0 , prevEndTime = INT_MIN; for( int i = 0 ; i < n ; ++i) { if( intervals[i][0] < prevEndTime) { count++; prevEndTime = min(prevEndTime, intervals[i][1]); } else { prevEndTime = intervals[i][1]; } } return count; }
Whenever your heart is broken
Don't ever forget you're golden
I will find a light in your soul
I'll be there
Never leaving you in the darkness
Even when you're out of focus
I will be the light in your life
You'll see clear
I'll be your inspiration
'Cause I know that you'll do just what you're told
I'll be your hard-earned temptation, yeah
'Cause I know that you'll make it on your own
Baby, you can count on me now
When you're falling down, down, down
I will find a light in your soul
I'll be there
Leaving you alone is the hardest
Even when you're out of focus
I will be the light in your life
You'll see clear
I'll be your inspiration
'Cause I know that you'll do just what you're told
I'll be your hard-earned temptation, yeah
'Cause I know that you'll make it on your own
I'll be your inspiration
'Cause I know that you'll do just what you're told
I'll be your hard-earned temptation, yeah
'Cause I know that you'll make it on your own
Yeah, on your own
-----------------------------------------------------
yes you are our inspiration striver 🥰
the way you find relation with other problems is amazing. thank you!
since code was not on website here is it for everyone:
class Solution {
public:
static bool comp(vector&a,vector&b){
return a[1]
thanks
as soon as I listened n meetings in a room I rushed back to questions. I was struggling with my approach but as soon I heard the title n meetings I got the solution .
Sir please start making videos on strings and stacks
Understood
thanks
Can anyone explain for this problem as well as for N meetings problem, why are we sorting based on end time and not on the length of the interval??
Yeah I had the same doubt, it can be cleared with an example:
Lets say we have [(0,3),(2,4),(3,6)]
According to you, if we sort by the length of the intervals, we'll complete (2,4) first - effectively blocking (0,3) and (3,6)
Instead if we sort by end times, we'll get (0,3)(3,6) as valid non clashing intervals.
Sorting based on length of the intervals doesn't give an optimal substructure.
@@yashmundada2483 but in this question if i sort based on start time it will work but in the n meeting it wont can u figure out why ?
understood
nice
US
Thank you
Understood
Great work pro I hope you are doing extremely well ❤
I sorted the array with respect to start time in ascending order. While traversing, if start_time of the current interval is greater than end time of the previously selected interval, then we would need to remove one interval, and we would remove that interval whose end time is lesser. it works .
bool compare(vector& a, vector& b) {
if ( a[0] < b[0]) return true;
if ( a[0] == b[0]) {
return a[1] < b[1];
}
return false;
}
int eraseOverlapIntervals(vector& intervals) {
int n = intervals.size();
if ( n == 1) return 0 ;
sort(intervals.begin(), intervals.end(), compare);
int count = 0 , prevEndTime = INT_MIN;
for( int i = 0 ; i < n ; ++i) {
if( intervals[i][0] < prevEndTime) {
count++;
prevEndTime = min(prevEndTime, intervals[i][1]);
} else {
prevEndTime = intervals[i][1];
}
}
return count;
}
this problem should be redundant if I solved last n meetings in room
How you got an idea of n meetings for this problem???
Wait is finally over now 😊😊
Waiting for this series ❤❤
thanks