Ordered Set

Asked at Databricks· Screen

Reported by the problem's creator, not verified

Import another question

SnapshotSet is a set of integers that remembers the order in which values were added. Removing a value and adding it again counts as a new addition, so the value moves to the end of that order.

Examples

  1. Example 1

    Input: init = [], operations = [["add",[3]],["add",[1]],["add",[3]],["add",[2]],["remove",[1]],["contains",[1]],["values",[]],["add",[1]],["values",[]]]

    Output: [true,true,false,true,true,false,[3,2],true,[3,2,1]]

    Explanation: Adding 3 twice inserts it once, so the second add returns false. Removing 1 leaves [3, 2]; adding 1 again treats it as newly added, so it lands at the end.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.