FastPrepFind a Linked-List Cycle Entry
Problems/Find a Linked-List Cycle Entry

Find a Linked-List Cycle Entry

Expedia logoExpedia● MediumNEW GRADINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report explicitly follows cycle detection with finding the node where the loop starts. An indexed next-pointer table rooted at node 0 and the no-cycle result are practice-interface choices. Estimated source match 95%.

A singly linked list is represented by a table next. Row index i identifies node i, and next[i] is its next node ID. The value -1 means null.

Start at node 0. Return the ID of the node where its reachable cycle begins: the first node revisited during this traversal. Return -1 if traversal ends at null or the table is empty. Nodes outside the chain reachable from node 0 do not affect the answer.

Function

cycleEntry(next: int[]) → int

Examples

Example 1

next = [1,2,3,1]return = 1

Traversal is 0,1,2,3,1. Node 1 is the first repeated node, so it is the cycle entry.

Example 2

next = [1,2,0]return = 0

Traversal returns to the head: 0,1,2,0. The cycle begins at node 0.

Example 3

next = [1,2,-1]return = -1

Traversal 0,1,2 reaches null without repeating a node.

Constraints

  • 0 <= next.length <= 20000.
  • -1 <= next[i] <= 19999.
  • Every next entry is -1 or a valid index in the same table.

More Expedia Onsite Interview questions

  • Scramble StringONSITE INTERVIEW · Seen Sep 2026
  • Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
  • Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
  • Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
  • Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
  • Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
  • Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
  • Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
  • Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
  • Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024

Similar questions at other companies

  • Detect a Linked-List CyclePaytm · ONSITE INTERVIEWPaytm interview questions
  • Detect a Linked-List CycleCapgemini · ONSITE INTERVIEWCapgemini interview questions
  • Detect a Linked-List CycleMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • First Node Two Linked Lists ShareAdobe · PHONE SCREENAdobe interview questions
  • Where Two Linked Lists MeetNutanix · PHONE SCREENNutanix interview questions
  • Shortest Window with Required CountsOracle · ONSITE INTERVIEWOracle interview questions
  • LRU CacheLotusFlare · ONSITE INTERVIEW
  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Remove Nth Node From End of ListDruva · ONSITE INTERVIEW
  • LRU CacheJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions

Interview reports that mention this question

  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia New Grad SDE Earlier Loops: 5 Experiences (Part 2 of 3)

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public int cycleEntry(int[] next) {
        // Write your code here.
    }

}
Checking account…