Samsung Electronics Interview Question

Question based on subinterval (Dynamic programming)