Tuesday, 25 August 2020

Sorting and Searching [CSES] [Day-2]

Movie Festival

Given starting and endings time of movies, return maximum number of movies we can watch. Could come up with recurcive solution where f(1...n) = max ( 1 + f(k...n), f(2..n)) which can be memoized and dp can be used to reduce the time taken. But it seems there is a greedy approach where we sort by ending time and watch it in that order. It seem to give the maximum number of movies. Need to prove it. Two action items pending here - 
    1. Implement DP approach. 
    2. Prove this greedy approach

.

No comments:

Post a Comment

Write Ahead Logging

In applications that needs to run continuously, ability to recover is key when a component goes down. If the component is transactional in n...