Logic Teasers; Editions 1; Linked Lists

This begins a series of posts where I drop little logic and core programming questions which I come across as a kind of repository for the little brain teasers that I come across in my daily life and profession. This was posed to me just today; it’s not that difficult, but the challenge is thinking on your feet and coming up with a decent and reasonable solution in a relatively short space of time.

Problem definition;

So you have a pair of linked lists. Each linked list contains a finite series of digits, and each list is exactly the same length (although you don’t know what that length is) and you can only traverse each list once.

Come up with an efficient algorithm for adding the base-10 representation of these numbers, given the constraints above.


About this entry