This is a question other people have already posted.
The input is three parameters. The first one is the pins that belong to each topic board. For example, a travel board has pins for maple leaves, ocean waves, and a lake, and a home board has pins for a bedroom, a living room, and renovation. So one topic covers an array of pins.
The second parameter is the starting pin, and the third parameter is the destination pin.
You have to find the score, where the score means the fewest steps it takes to get from the starting pin to the destination pin.
For example:
- Travel: California, New York, Washington
- Food: New York, Sichuan food, Cantonese food
- Sports: tennis, basketball, California
Then going from California to Cantonese food is 1, because New York belongs to two boards at the same time. But going from New York to basketball is 0, because there's no way to move between the boards.
Honestly, BFS is all you need, just with a slight twist.
I wrote it with BFS and all the tests passed. When I finished there were still ten minutes left. The interviewer didn't say anything, just asked whether I had any questions, and then ended the interview. I have no idea where I failed. But during the interview I felt the interviewer didn't look very friendly. Maybe luck is part of skill too. On these days without a job, I don't even know what I should be doing to keep my life from standing still and going nowhere.
Discussion
Loading comments…