[Uber] OA 2025 Start – 22 Feb (Generic)

A group of intrepid adventurers set out to discover a mysterious artifact with a series of ancient symbols etched along its circular edge. The order of these symbols has long been lost, but a collection of symbol pairs known to be adjacent to each other was found. Unfortunately, the pairs of symbols became jumbled over time, meaning each pair (x, y) could be recorded either as (x, y) or (y, x). You are given an array symbolPairs representing these shuffled pairs, and your task is to rediscover the original sequence of symbols on the artifact's circular edge.

Remember that any cyclic rotation of the sequence can be considered a correct solution, and the order of the sequence can be reversed as well because the circle has no fixed start or end. Please return any of the valid arrangements.

Example

  • For symbolPairs = [[3, 5], [1, 4], [2, 4], [1, 5], [2, 3]], the output can be
    solution(symbolPairs) = [3, 5, 1, 4, 2]

Input/Output

  • [execution time limit] 3 seconds (java)
  • [memory limit] 1 GB
  • [input] array.array.integer symbolPairs A list of pairs of symbols that are adjacent on the artifact. All symbols on the original circle are guaranteed to be distinct. Guaranteed constraints:
    2 ≤ symbolPairs.length ≤ 10⁵
    symbolPairs[i].length = 2

我们长期稳定承接各大科技公司如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 *