FastPrepReconstruct Island Visit Order
Problems/Reconstruct Island Visit Order

Reconstruct Island Visit Order

Visa logoVisa● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A December 16, 2025 Visa Senior Software Engineer CodeSignal OA report gives the pairs of consecutive islands and the complete example path. The report accepts either path direction, so our version adds a fixed rule that uses the larger endpoint, limits, and a descriptive function name.

You visited a sequence of unique islands but forgot their exact order. Each pair in consecutiveVisits contains two islands that were visited consecutively; either island may have come first.

Reconstruct the complete visit order. Every island appears exactly once, and every adjacent pair in the returned order must correspond to one supplied pair.

The pairs are guaranteed to describe one simple path containing every island. A path and its reversal both satisfy the adjacency evidence, so return the orientation that starts from the numerically larger endpoint.

Function

reconstructIslandVisitOrder(consecutiveVisits: int[][]) → int[]

Examples

Example 1

consecutiveVisits = [[1,2],[2,3],[4,5],[1,5]]return = [4,5,1,2,3]

The pairs connect the path 4 - 5 - 1 - 2 - 3. Its endpoints are 3 and 4. The path must start from the larger endpoint, 4.

Constraints

  • 1 <= consecutiveVisits.length <= 105
  • Every element of consecutiveVisits contains exactly two distinct island IDs in the range [-109, 109].
  • The undirected pairs form one simple path and contain no duplicate edge.
  • Return the path starting from the numerically larger of its two endpoints.

More Visa Online Assessment questions

  • Count Prime Values in SubtreesOA · Seen Nov 2026
  • Lock CodeOA · Seen Nov 2026
  • Minimum-Sum Tree Fill with Unit StepsOA · Seen Nov 2026
  • Longest Non-Decreasing Substring After Pair SwapsOA · Seen Oct 2026
  • Count Attack Vectors by Divisor RangeOA · Seen Oct 2026
  • Minimum Operations to Reduce a Transaction LedgerOA · Seen Oct 2026
  • Count Valid Space-Delimited WordsOA · Seen Oct 2026
  • Earliest Common Meeting StartOA · Seen Oct 2026
  • Maximum Index-Weighted Sum with Disjoint SwapsOA · Seen Oct 2026
  • Maximum Equalized Substrings After One Adjacent SwapOA · Seen Sep 2026

Similar questions at other companies

  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Accounts MergeOracle · ONSITE INTERVIEWOracle interview questions
  • Generate All Contiguous Protein ChainsBenchling · PHONE SCREENBenchling interview questions
  • Shortest Path Through Numbers Sharing a DigitGoogle · PHONE SCREENGoogle interview questions
  • Jump Game IVZomato / Eternal · ONSITE INTERVIEWZomato / Eternal interview questions
  • Initial and Final Accounts in a Transfer ChainAmazon · PHONE SCREEN
  • Bus RoutesBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • API Rate Limit Violation DetectionTekion · OATekion interview questions
  • Count Pairs of Overlapping SquaresCapital One · OACapital One interview questions
All Visa interview questionsSee Visa hiring insights
Saved
class Solution {
    public int[] reconstructIslandVisitOrder(int[][] consecutiveVisits) {
        // Write your code here.
    }

}
Checking account…