Using dp for this problem

Can this be solved with dp, if yes, can you provide me with a solution, it is in recursion section in the course, also, would greedy work here, please help?

Yes, we can use DP for this problem, greedy however will not work here.
Let me give you a dp solution for this, it is much similar to the recursive one, at each step you just need to find whether an element gives the best answer while being included or excluded.