Problem Β· Hash Table

Sign In Pages 🍊

Learn this problem
● EasyAmazonINTERNOA
See Amazon hiring insights

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:

    1. String[] requests: an array of API requests

    Returns

    String[]: an array of responses for each API request

    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:

    1. register david david123 - The user 'david' is registered successfully.
    2. register adam 1Adam1 - The user 'adam' is registered successfully.
    3. login david david123 - The user 'david' logs in successfully.
    4. login adam 1adam1 - The login is unsuccessful because the password is case-sensitive and does not match the registered password '1Adam1'.
    5. logout david - The user 'david' is logged out successfully.

    More Amazon problems

    drafts saved locally
    public String[] signInPages(String[] requests) {
        // write your code here
    }
    
    requests["register david david123", "register adam 1Adam1", "login david david123", "login adam 1adam1", "logout david"]
    expected["Registered Successfully", "Registered Successfully", "Logged In Successfully", "Login Unsuccessful", "Logged Out Successfully"]
    checking account