158. Previous Left Sibling

JavaScriptDOM

medium  - accepted / - tried

Given a DOM tree and a target element, please return the previous left sibling.

Like above, the previous left sibling of green <a/> is the blue <button/>. Notice that they don't necessarily have the same parent element.

If no left sibling, then return null.

What is time & space cost of your solution ?

Bugfree ordinary solution is better than buggy fancy ones.

(72)