Amazon Coding Question – Solved

9 Live
A service maintains a database with three string columns: Column Name | Description ------------|------------ user_id | The user ID of the user who created the URL short_url | The shortened URL actual_url | The actual URL to redirect to There are m users with ids from 0 to m - 1 and q requests for the short URLs. For each request i, report the actual URL and the number of requests processed for the user who created the short URL till the i-th request. Given an array of n strings, database, where the i-th row is represented by the string database[i] in the format "<user_id> <short_url> <actual_url>", and q queries represented by the array of strings, queries, for each requested short URL, report an array of strings of length 2 with the actual URL and the number of times a request is made using a short URL created by a particular user. Example Suppose there are m = 3 users, database = ["0 sdsf www.google.com", "1 juytf www.google.com", "0 opoit www.kaggle.com"], and requests = ["juytf", "sdsf", "opoit"]. Short URL | Actual URL | Created By | Count for User -----------|------------|------------|--------------- juytf | www.google.com | 1 | 1 sdsf | www.google.com | 0 | 1 opoit | www.kaggle.com | 0 | 2

Asked in: Amazon

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |