Skip to content

Instantly share code, notes, and snippets.

@vdparikh
Last active September 6, 2023 17:30
Show Gist options
  • Select an option

  • Save vdparikh/2256be0fad358227b0c1bc48e853d3a9 to your computer and use it in GitHub Desktop.

Select an option

Save vdparikh/2256be0fad358227b0c1bc48e853d3a9 to your computer and use it in GitHub Desktop.

Revisions

  1. vdparikh renamed this gist Sep 6, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. vdparikh created this gist Sep 6, 2023.
    55 changes: 55 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    The following coding problem requires Senior engineer level or up to finish two questions within 50 minutes.

    We are working on a security system for a badged-access room in our company's building.
    1. Given an ordered list of employees who used their badge to enter or exit the room, write a function that returns two collections:
    a. All employees who didn't use their badge while exiting the room – they recorded an enter without a matching exit.
    b. All employees who didn't use their badge while entering the room – they recorded an exit without a matching enter.

    ```
    badge_records = [
    ["Martha", "exit"],
    ["Paul", "enter"],
    ["Martha", "enter"],
    ["Martha", "exit"],
    ["Jennifer", "enter"],
    ["Paul", "enter"],
    ["Curtis", "enter"],
    ["Paul", "exit"],
    ["Martha", "enter"],
    ["Martha", "exit"],
    ["Jennifer", "exit"]
    ]
    ```

    Expected output: `["Paul", "Curtis"], ["Martha"]`

    2. We want to find employees who badged into our secured room unusually often. We have an unordered list of names and access times over a single day. Access times are given as three or four-digit numbers using 24-hour time, such as "800" or "2250".
    Write a function that finds anyone who badged into the room 3 or more times in a 1-hour period, and returns each time that they badged in during that period. (If there are multiple 1- hour periods where this was true, just return the first one.)
    Notice that "10:00" - "11:00" is considered to be within a one-hour period, while "22:51" - "23:52" is not considered to be within a one-hour period.

    ```
    badge_records = [
    ["Paul", 1315],
    ["Jennifer", 1910],
    ["John", 830],
    ["Paul", 1355],
    ["John", 835],
    ["Paul", 1405],
    ["Paul", 1630],
    ["John", 855],
    ["John", 915],
    ["John", 930],
    ["Jennifer", 1335],
    ["Jennifer", 730],
    ["John", 1630],
    ]
    ```

    Expected output:
    `{"John": [830, 835, 855, 915, 930], "Paul": [1315, 1355, 1405]}

    Time: O(N) , Space: O(N) .