Frage im Vorstellungsgespräch bei LinkedIn

Program a function which determines if one document node contains another node.

Antwort im Vorstellungsgespräch

Anonym

1. Mai 2015

At first I designed a function which recursively walked through the DOM tree from top to bottom, comparing nodes. The developer asked me to refactor the function to improve performance, hinting that I should switch directions. I then developed a function which went from the bottom of the nodes up, recursively. I was then asked to remove the recursion of this function which I solved for by using a for loop and swapping variables in and out.