Google interview question

Question based on arrays, sorting n dp