I was give question in interview. They tell me robot is standing on line. Not queue, just number line, which go left and right forever.
Robot have starting place in list called nums. Also robot have direction in string s. Like if s = RLL, then first robot go right, second and third go left.
All robot start walking when command say GO
But twist come — if two robot hit each other, they do not break or cry. They just turn around and go other way. Like, oh sorry, you first.
Now, interviewer tell, after d seconds, what is total distance between all robots pair
I was thinking, ok robot move, maybe some come back, maybe not.
I write code, but it not work. I forget to handle collision. I thought robots become friends and go together. But no, they bounce back.
Then I try fix but my brain not walk like robot. I was confuse how to find all distance between robot pairs.
I say, sir, can I write brute force. He said, you have five minutes left.
Then I smile and cry inside.
post interview I read again. Now I understand. But interview already gone.