Coding · Hard · ProCandy distribution with ratingsCodingGreedyStaffModel answerPreviewApproachClarify constraints and edge cases for: Candy distribution with ratings.Choose appropriate data structure; state time/space…