Whatnot Interview Question

Weird implementation of Binary search and stack