My Experience: Problem solving techniques (Example problems) (Cont.)
In this post i will show you when to use graphs to solve specific type of problems. To know about graphs and other problem solving techniques you may need to read this.Problem 14 (Shortest path)
Given a set of cities' paths represented as a two dimensional array grid where grid[i][j] = 1 iff there exists a path between city i to city j. Given two cities src and dst, find the shortest path to go from src to dst. If there is no such path return -1.
Solution // In this problem i will show you how to use BFS to get shortest path
Read full article from My Experience: Problem solving techniques (Example problems) (Cont.)
No comments:
Post a Comment