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?
Similar Posts
- Valid Dictonary String - Bloomberg - Port Interactive Analytics - Full Stack - 11/8/21
- Microsoft Fill Paint - Bloomberg - Port Interactive Analytics - Full Stack - 12/6/21
- Sort Tree - Bloomberg - Port Interactive Analytics - Front End - 12/6/21
- Van Ecks Sequence - Bloomberg - Asset Management AIM - Full Stack - 11/5/21
- Flexible UI Component - Bloomberg - Asset Management AIM - Full Stack - 12/6/21
- 2D Array Path - C3 AI - CRM - Full Stack - 11/11/21
- Compressed String with Sort - C3 AI - CRM - Full Stack - 11/11/21