Given a graph with M edges and N vertices with Source as Node 1 and destination as Node N. Each node has a color either black or white , and the edge has some weight associated with it.How to find the shortest path between source and destination with the condition that the difference between the black and white nodes is atmost 1.

I know how to solve this problem without the condition

Now,with the condition how to solve this problem.

PS:asked in hiring challenge

please explain the approach