Amazon Coding Question – Solved

2 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

| The supply chain manager at one of Amazon's warehouses is shipping the last con… |
| Determine the highest value after executing n steps on an infinite 2D grid that… |
| Amazon Prime Video is developing a new feature called "Segmentify." This featur… |
| In this new stock prediction game launched on Amazon Games, Player 1 provides P… |
| Amazon operates numerous warehouses, with each warehouse holding inventory[i] u… |
| In Amazon's highly efficient logistics network, minimizing operational overhead… |