Hi, have been trying to solve this problem. I am only missing one test case but that is really big, therefore I am not able to debug my code now. Can you please tell me what am I am doing wrong.
problem link: CSES - Movie Festival
code link: https://cses.fi/paste/c3b2a6ef0510a27812d5e2/
Algorithm
sort the array of <start_time,end_time> by end_time in asc order.
inititiialize prev = 0, next = 1, movies_watched = 1;
int next= 1, prev = 0;
while (next <= n - 1 && prev <= n - 1)
{ // if ending time of prev movie <= start_time of next movie, I can watch next movie
if (movie_times[prev].second <= movie_times[next].first)
{
movies_watched++;
next++;
prev++;
}
else
// I can't watch next movie, only increment prev
{
prev++;
}
}