Flipkart interview question

Rat and maze problem