Google | Onsite | SDE
Anonymous User
1460

There are three input formats, timestamp.

  1. [time, "Set", fileName, Value]
  2. [time, "Connect", fileName, fileName]
  3. [time, "Remove", fileName]

In the first one, we set file and it's value. In the second one we need to concatenate the files for value , the third one is about removing that fileName.
Given these, we need to support a search operation - search(time, fileName)
For example : input
[[0, "Set", "A", 1],
[1, " Set", "B", 2],
[2, "Connect", "A", "B"],
[3,"Remove", "B"]]
search(0, "A") -> [["A", 1]]
search(1, "A") -> [["A", 1]]
search(1, "B") -> [["B", 2]]
search(2, "B") -> [[ "B", 2], ["A", 1]] # Can be any order
search(2, "A") -> [["B", 2], ["A", 1]] # Can be any order
search(3, "B") -> []
search(3, "A") -> [["A", 1]]
search(4, "A") -> [["A", 1]]

How do we do this question ?

Comments (5)