Hey y’all! I got another solution up for Leetcode 138 Copy List with Random Pointer as well as its variant.
This question is frequently asked and for once, we have things going our way: not only do Meta interviewers expect the O(N) space complexity solution but they also rarely ever ask the variant. You’ll be happy to know this because the variant is to copy random pointers in a binary Tree, no longer a linked list. Tbh screw that but at least the two-traversal solution with space is acceptable.
DISCLAIMER: I have no doubt some interviewers go rogue and poke and prod for the O(1) space solution. It's rare though!
Reference to the OG LC problem: https://leetcode.com/problems/copy-list-with-random-pointer/
Good luck on your phone screens & onsite loops.