Can BFS find shortest path? Technically, Breadth-first search (BFS) by itself does not let you find the shortest path, simply becauseBFS is not looking for a shortest path: BFS describes a strategy for searching a graph, but it does not say that you must search for anything in particular...
Output: 16 Explanation: You will be initially given box 0. You willfind7 candiesinit and boxes 1 and 2. Box 1 is closed and you don't have a keyforit so you willopenbox 2. You willfind4 candies and a key to box 1inbox 2. In box 1, you willfind5 candies and box 3 but you...