I started my studying today by looking at Programming Interviews Exposed. The author indicates that linked-list problems are common in coding interviews, because they can be solved relatively quickly, but they still expose the coder's thought processes.
As a Java programmer, I don't have much use for linked lists. Java includes a LinkedList class that takes care of all the operations for me. But according to the book, I might still be asked to implement a linked list of my own and solve some linked list problems... because it will expose my thought process.
Okay, I remember linked lists from back when I was a hot-shot C programmer. (I used to think Java was a flash in a pan. With the recent security vulnerabilities, it may turn out that way after all.) I can do this. But perhaps I should pass on the brain teaser for today. The list problems can be my brain teaser.
Implement a singly-linked list. Given a doubly-linked list (with tail pointer) where each node may have a doubly-linked list (without head or tail pointers) as a child, and the children may have their own children, flatten it to a plain doubly-linked list. Now put it back.Continue reading "Interview Prep Day 4: Linked Lists" »