โœจ

Recommendation Engine

Recommend items by matching tags, scoring and ranking โ€” without recommending what the user already liked.

Project 13Advanced

๐Ÿงฉ Problem statement

Each item has tags. A user has liked some items. Score every other item by how many tags it shares with the userโ€™s liked items (count shared tags per liked item). Show the top 3 as “ITEM (SCORE)”, highest first; ties keep the catalogue order.

๐Ÿ“‹ Requirements

  • Matching
  • Scoring
  • Ranking
  • Similarity

๐Ÿ“ฅ Inputs

  • ITEMS: map item โ†’ list of tags
  • LIKED: list of items

๐Ÿ“ค Outputs

  • Top 3 recommendations with scores

๐Ÿ“ Rules

  • Never recommend an already-liked item
  • Ties: catalogue order

๐Ÿšง Constraints

  • Each item has 1โ€“5 tags

๐Ÿงญ Suggested approach

  • Collect the tags of liked items
  • Score each other item by shared tags
  • Pick the top 3 by repeated max

๐Ÿง  Required concepts

  • Maps
  • Lists
  • Counting
  • Ranking
โœ๏ธ Pseudocode editor ยท dry-run tool ยท test cases

Design your solution here. Use Run to dry-run it step by step and Run tests to check it. Hints unlock one at a time โ€” try on your own first!

๐Ÿงช Edge cases to test

  • A user who liked nothing
  • Fewer than 3 items left to recommend
  • Many ties

๐Ÿ“ˆ Complexity analysis

Weights O(liked ร— tags); scoring O(items ร— tags); ranking O(3 ร— items).

๐Ÿ“– Solution walkthrough (open after youโ€™ve tried!)

First the liked itemsโ€™ tags are counted into a weight map โ€” tags the user likes more get bigger weights. Each other item scores the sum of the weights of its tags. Ranking picks the highest score three times (strictly greater keeps catalogue order on ties) and removes each pick so it isnโ€™t chosen again.

๐Ÿš€ Challenge extensions

  • Use similarity between users (people who liked X also liked Y)
  • Penalise items with tags the user disliked
  • Explain why each item was recommended

โ† All projects