Graduate RTL Hardware Design Engineer Interview
There are 5 holes in a line, and there is a rat in one of it. Each turn the rat will move either left or right, but never stay in the same hole, and each turn you can check one hole. The holes are in a line so when the rat reach one end, it must move back in the next turn. What is your strategy to catch that rat?
start with middle move to 2nd and check twice and move to 3rd and then 4th and check 4th twice.. right? OR you start anywhere just move sequentially and check 2nd and 4th place twice
middle to 2nd not needed
Keep checking middle one, worst case delay is 4 check, and you should find it by then!!
Add Answers or Comments
To comment on this, Sign In or Sign Up.