FastPrepPlanets Queries from Planet One
Problems/Planets Queries from Planet One

Planets Queries from Planet One

Adyen logoAdyen● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report says every query starts at planet 1. It does not give the function signature, so we chose it.

Our version is about 95% the same as the reported question.

There are n planets numbered from 1 to n. Every planet has exactly one teleporter, possibly to itself. The array nextPlanet stores these destinations: the teleporter from planet i goes to nextPlanet[i - 1].

Every query starts on planet 1. For each value steps[j], follow exactly that many teleporters and return the planet reached. Return the answers in query order.

Function

planetsFromOne(nextPlanet: int[], steps: int[]) → int[]

Examples

Example 1

nextPlanet = [2,1,1,4]steps = [0,1,2,3,1000000000]return = [1,2,1,2,1]

The orbit from planet 1 alternates between 1 and 2. Zero steps stays at the start, and the billion-step query lands on planet 1.

Example 2

nextPlanet = [2,3,4,5,3]steps = [0,1,2,3,4,5,6]return = [1,2,3,4,5,3,4]

The route has a two-edge tail before entering the cycle 3 -> 4 -> 5 -> 3.

Example 3

nextPlanet = [1]steps = [0,1,999999999,1000000000]return = [1,1,1,1]

Planet 1 teleports to itself, so every query returns 1.

Constraints

  • 1 <= nextPlanet.length == n <= 2 * 10^5
  • 1 <= nextPlanet[i] <= n
  • 1 <= steps.length <= 2 * 10^5
  • 0 <= steps[j] <= 10^9

More Adyen interview questions

  • Search and Format ContactsPHONE SCREEN · Seen Nov 2026
  • Count Perfect PairsOA · Seen Aug 2026
  • Find the Tree DiameterONSITE INTERVIEW · Seen Aug 2026
  • Maximize Strength with Disjoint Adjacent SwapsOA · Seen Aug 2026
  • Best TV Show in a GenreOA · Seen May 2026

Similar questions at other companies

  • Select Transactions with Child-Pays-for-Parent PackagesCoinbase · PHONE SCREENCoinbase interview questions
  • Cheapest Flights Within K StopsGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Largest Consistent Visiting GroupAuxoAI · OA
  • Parallel Courses IIIGoogle · ONSITE INTERVIEWGoogle interview questions
  • Fewest Coins CombinationBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • All Halfway Courses Across Course TracksCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • Longest Increasing SubsequenceByteDance · PHONE SCREENByteDance interview questions
  • Jump GamePaytm · PHONE SCREENPaytm interview questions
  • Query Words Within K PositionsPalantir · PHONE SCREENPalantir interview questions

Adyen interview experiences

  • Adyen Kotlin Backend Engineer Live Coding: 1 Experience
All Adyen interview questionsSee Adyen hiring insights
Saved
class Solution {
    public int[] planetsFromOne(int[] nextPlanet, int[] steps) {
        // write your code here
    }
}
Checking account…