I just got out of an interview with TikTok and they asked a very weird question.
So the question was there is parking lot with spots connected to each other. The cars have a particular color and each parking spot except for a minmum one does not. You need to move the cars to the right spot.
(Yellow Spot [Red Car])---(Green Spot [Yellow Car])
/ \
/ \
(Red Spot [Green Car])------------(No color Spot [No Car])
The results should be a list of instructions on how each car should move and get to the right spot. Naturally the car can move to an empty spot and one car can move each turn
I tried breaking it down into smaller parts like lets say its one car from start to end use DFS or BFS.
But then was running out of time and decided to use a brute force to keep trying moving every car until the cars were in their right spot.
Can anyone help me here?
What is the solution?
Also for a first rount 45 mins interview seems like an intense question?
We have to write the code and the write the test code to complie and execute it.