✨

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