QUESTION

As an intern at Amazon, you have been assigned a task to implement the sign-in pages in the Amazon Dummy Website. There are three sign-in pages, each with its own API: Register Login Logout Function Registers a new user with the username and password username logs out of the website Verifies the username and password, then grants or denies access API Request register login logout Returns • If the registration was successful, Registered Successfully • If the user already exists, Username already exists • If the login was successful, Logged In Successfully • If the login was unsuccessful Login Unsuccessful • If the logout was successful, Logged Out Successfully • If the given username wasn't logged in Logout Unsuccessful Given a log of API requests, return the list of returns from the mock website. Given a log of API requests, return the list of returns from the mock website. 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 origi login remains active. • Each log is an API request and is in one of the three allowed formats. • The order of execution of each request is the same as the order of input. • The usernames and passwords are case-sensitive. Example The website receives the following API requests in order: . • register user 05 qwerty • A new user with the username "user05" is registered to the website with the password "qwerty o The return value isRegistered Successfully login useros qwerty o There is a user with that username. The password matches that user's password. The user is not already logged in. • The login is successful and the return value is Logged In Successfully • logout user 5 The user with username "user 05" is currently logged in. • The logout is successful and the return value is Logged Out Successfully Return the array ("Registered Successfully", "Logged In Successfully", "Logged Out Successfully"). Function Description Complete the function implementAPI in the editor below. implementAPI has the following parameter: string logs[n]: each of the API requests Returns string(n): an array of strings where th string is the return value of the ith API request Constraints . isnsios . 15 username , I password | s10 (where Is is the length of strings) • username and password are alphanumeric strings, ranges [0-9, a-z, A-Z] Input Format For Custom Testing The first line contains an integer, n, the number of elements in logs. Each line of the n subsequent lines (where 0 si)

Public Answer

TAO3B1 The First Answerer