I knew in-order traversal was the right move pretty fast.
Use an in-order traversal to visit nodes in sorted order, relinking left and right pointers as you go to form the doubly linked list. After traversal, connect the head (smallest) and tail (largest) to make it circular, then return the head.
Pro tip: Clarify whether the conversion should be done in-place and whether recursion is acceptable; if not, mention that an iterative in-order traversal with a stack can achieve O(1) extra space (excluding stack).
Confirm that the transformation is in-place, that left/right pointers become predecessor/successor, and that the list must be circular. Ask about recursion depth limits or space constraints.
Perform an in-order traversal (recursive or iterative) to process nodes in ascending order. Maintain a 'prev' pointer to the last processed node and a 'head' pointer for the smallest node.
For each node, set its left pointer to 'prev' and, if 'prev' exists, set 'prev.right' to the current node. Update 'prev' to the current node.
After traversal, connect the head's left pointer to the tail (last processed node) and the tail's right pointer to the head.
Return the head (smallest element). Test with empty tree, single node, and skewed trees to ensure correctness.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.