#=
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.
=#

global log = []
global N = 5

function changeN(N_new::Int64)
    global N = N_new
end

function record(order_id)
    if length(log) +1 <= N
        append!(log, order_id)
    else
        popfirst!(log)
        append!(log, order_id)
    end
end

function get_last(i::Int64)
    if i <= length(log)
        return log[end - i + 1]
    else
        return "i is too large"
    end
end
