The Times of India homepage receives article objects from multiple feed sources. Prepare a UI-ready list of article cards by filtering eligible articles, removing duplicate IDs, ranking the remaining articles, and selecting a maximum number of results.
Implement prepare_feed(items, category, min_score, limit).
isPublished is True, category matches the requested category, and score is at least min_score.limit objects, mapped to only these fields: id, title, imageUrl, and score.Input is an array of objects with fields id and title as strings, category as a string, isPublished as a boolean, score as an integer, and imageUrl as a string. category is a string, min_score is an integer, and limit is a non-negative integer. Return an array of mapped objects in ranked order.
Example 1: items = [{id: "a", title: "A", category: "sports", isPublished: true, score: 80, imageUrl: "a.jpg"}, {id: "b", title: "B", category: "sports", isPublished: true, score: 95, imageUrl: "b.jpg"}], category = "sports", min_score = 70, limit = 2 returns [{id: "b", title: "B", imageUrl: "b.jpg", score: 95}, {id: "a", title: "A", imageUrl: "a.jpg", score: 80}].
Example 2: Duplicate IDs retain the higher-scoring article, while unpublished or mismatched articles are excluded.
1 <= items.length <= 10^50 <= limit <= items.length0 and 10^9.def prepare_feed(items, category, min_score, limit):