Amazon Interview Report
- 0of 0 votes
AnswersYou have rating (0-10) of the hotels per user in this format:
- theconqueror July 06, 2016 in United States
scores = [
{'hotel_id': 1001, 'user_id': 501, 'score': 7},
{'hotel_id': 1001, 'user_id': 502, 'score': 7},
{'hotel_id': 1001, 'user_id': 503, 'score': 7},
{'hotel_id': 2001, 'user_id': 504, 'score': 10},
{'hotel_id': 3001, 'user_id': 505, 'score': 5},
{'hotel_id': 2001, 'user_id': 506, 'score': 5}
]
Any given hotel might have more than one score.
Implement a function, get_hotels(scores, min_avg_score) that returns a list of hotel ids that have average score equal to or higher than min_avg_score.
get_hotels(scores, 5) -> [1001, 2001, 3001]
get_hotels(scores, 7) -> [1001, 2001]
*/
How to solve this in C++ and Python?| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
AnswersThere is an input log file given as follows-
- theconqueror July 06, 2016 in United States
log = [
{ 'user': 'A', 'page': 1},
{ 'user': 'B', 'page': 5},
{ 'user': 'A', 'page': 2},
{ 'user': 'A', 'page': 1},
{ 'user': 'B', 'page': 2},
{ 'user': 'C', 'page': 7},
{ 'user': 'C', 'page': 3},
{ 'user': 'A', 'page': 3},
{ 'user': 'C', 'page': 1},
]
please implement
discover_site_map(log)
discover_site_map returns a representation of the links between pages, using whatever data structure you think is suitable:
1 -> 2, 3
2 -> 1
3 -> 1
5 -> 2
7 -> 3
How to solve this in C++ and Python?| Report Duplicate | Flag | PURGE
Amazon Software Engineer