Data Structures And Algorithms Interview Bit Javascript Question