How can i solve this problem.Is it greedy or Dp problem??? sorry for the bad image qualiy pic took during the coding round.....