Sign In Pages π
Updated
Problem statement
As an intern at Amazon, you have been assigned a task to implement the three sign in pages, each with its own API: Register, Login, Logout.
Notes:
- Initially, there are no users registered.
- If a user is already logged in and makes a login request, the new request is unsuccessful. The original login remains active.
- Each log is an API request and is in one of the three allowed formats.
- The order of execution of each requests is the same as order of the input.
- The username and passwords are case-sensitive.
Complete the function signInPages in the editor.
signInPages has the following parameter:
String[] requests: an array of API requests
String[]: an array of responses for each API request
Function
signInPages(requests: String[]) β String[]Examples
Example 1
requests = ["register david david123", "register adam 1Adam1", "login david david123", "login adam 1adam1", "logout david"]return = ["Registered Successfully", "Registered Successfully", "Logged In Successfully", "Login Unsuccessful", "Logged Out Successfully"]The sequence of API requests and their corresponding responses are as follows:
register david david123- The user 'david' is registered successfully.register adam 1Adam1- The user 'adam' is registered successfully.login david david123- The user 'david' logs in successfully.login adam 1adam1- The login is unsuccessful because the password is case-sensitive and does not match the registered password '1Adam1'.logout david- The user 'david' is logged out successfully.
More Amazon interview questions
- LRU Cache for Query ResultsPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026
- Maximal SquareONSITE INTERVIEW Β· Seen Nov 2026
- Serialize and Deserialize a Binary TreeONSITE INTERVIEW Β· Seen Nov 2026
- Course SchedulePHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026
- Course Schedule IIPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026
- Diagonal Traversal of a Binary TreeONSITE INTERVIEW Β· Seen Nov 2026
- Minimum Time to Spread Through a GridPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026
- Consistent-Hash Packet RouterPHONE SCREEN Β· Seen Nov 2026
- Count Connected ComponentsPHONE SCREEN Β· Seen Nov 2026
- Maximize K-Element AND with an Increment BudgetOA Β· Seen Nov 2026
Similar questions at other companies
- Blood Type Inheritance: Possible Parent GenotypesAbridge Β· OAAbridge interview questions
- Branch with the Most FilesCapital One Β· OACapital One interview questions
- Filter Transaction Logs and Calculate Reliability MetricsStripe Β· OAStripe interview questions
- Parcel Event TrackingAirbnb Β· OAAirbnb interview questions
- Versioned Recipe SystemThe Trade Desk Β· OA
- Cheating CodemakerJane Street Β· OAJane Street interview questions
- Aggregate Paginated Project Run RecordsReplit Β· OA
- Numbers Station Message DecoderOptiver Β· OAOptiver interview questions
- Hidden ArtifactsIMC Trading Β· OAIMC Trading interview questions
- SimpleRDD Word CountDatologyAI Β· PHONE SCREEN