Loading
Loading
A diagnostic tool needs the middle node of a processing chain without first measuring its length.
Return the chain starting from the middle node. When the chain has an even number of nodes, return the second of the two middle nodes.
1 → 2 → 3 → 4 → 5slow=1, fast=1start togetherslow=2, fast=3slow one step, fast twoslow=3, fast=5fast at the end, slow at the middle3 → 4 → 5Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(n) time · O(1) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
Example 2
Even length, so the second middle node is returned.
Example 3