Skip to content

Day 16 #35

Closed
Closed

Description

@vaskoz

Good morning! Here's your coding interview problem for today.

This problem was asked by Twitter.

You run an e-commerce website and want to record the last N order ids in a log. Implement a data structure to accomplish this, with the following API:

record(order_id): adds the order_id to the log
get_last(i): gets the ith last element from the log. i is guaranteed to be smaller than or equal to N.
You should be as efficient with time and space as possible.

Activity

  1. self-assigned this
    on Sep 6, 2018
  2. vaskoz commented on Sep 6, 2018

    @vaskoz
    OwnerAuthor

    I've decided to implement this two different ways.

    1. maintain a circular list myself using an array (not slice).
    2. use container/ring because I haven't used it before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions