Amazon Coding Question – Solved

5 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

| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |
| Undirected Coloured Graph Shortest Path You are given an undirected weight… |
| Village Voyage A computer game "Village Voyage" has N villages (labeled 1 to… |
| Academic Decathlon Students are being selected for an academic decathlon tea… |
| Sum of Arrays Given two arrays each of length n, arr1 and arr2, in one opera… |
| Count Swaps During Custom Sorting Analyze the efficiency of the following so… |