We.Vision Interview Question

I was asked to write a code to solve a data structure problem