Whatnot interview question

Weird implementation of Binary search and stack