Google Interview Question

Question based on arrays, sorting n dp