javascript

Recommendations - Bloomberg - Port Interactive Analytics - Full Stack - 11/8/21

- Build a recommendation system
- Given the likes of users, and a list of a user's likes, give recommendations 
1 A B C D
2 DC D 
3 C D

likes: B C

Returns [D, A] in this specific order (because D has two likes, and A only has one)


function reccomendations(dataSet: string[][], likes: string[])
  // hashmap D: 2, A: 1
  let currentRecommendations = {};
  loop over data set to get each individual user's likes 
    let isMatch = true;
    let currentReccomendations= []
    loop over each individuals likes 
      if data set user like is in likes
        matches++
      else isMatch = false
    if (matches == likes.length) 
     // Found a user match 
     add diff of user matches (e.g. reccomendations to currentRecommendations)

  // return currentRecommendations as a an array in sorted order
Was this helpful?