[cisco] OA Senior Hanging Sutra – 28 Apr (guide)

Part 1

Problem

Each router provides an array where each element is [timestamp, STATUS], with:

  • STATUS = 1 meaning Online from the previous timestamp (or from time 0 if it's the first entry) until the current timestamp.
  • STATUS = 0 meaning Offline during that same interval.

Given one router's log, return an array of [start, end] intervals where the router was Offline.

Input

[[5, ON], [7, OFF], [30, ON], [31, OFF], [36, ON]]

Output

[[5,7], [30,31]]

Part 2

Problem

Given an array representing multiple routers' offline intervals, return the combined offline intervals for the entire network.

Network is Offline at a given time if any router is Offline.

Input

[
  [[5, 7], [30, 31]],      // device 1
  [[6, 8], [10, 12], [31, 34]], // device 2
  [[6, 7], [9, 10]]        // device 3
]

Output

[[5, 8], [9, 12], [30, 34]]

Part 3

Problem

Given the merged offline intervals and the final timestamp, reformat into the original format: a list of [timestamp, STATUS] with status transitions.

Rules:

  • Start with Online (unless Offline at 0).
  • Switch statuses at each interval start and end.

Input

arg1 = [[5, 8], [9, 12], [30, 34]]
arg2 = 36

Output

[[5, ON], [8, OFF], [9, ON], [12, OFF], [30, ON], [34, OFF], [36, ON]]

Input

arg1 = [[0, 4], [5, 8], [9, 12], [30, 34]]
arg2 = 36

Output

[[4, OFF], [5, ON], [8, OFF], [9, ON], [12, OFF], [30, ON], [34, OFF], [36, ON]]

我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

Your email address will not be published. Required fields are marked *