Lintcode 207 Course Schedule
https://leetcode.com/problems/course-schedule/description We can follow the steps introduced in https://leetcode-solution.com/breadth-first-search to solve this problem. Let’s take a look at the solution:
https://leetcode.com/problems/course-schedule/description We can follow the steps introduced in https://leetcode-solution.com/breadth-first-search to solve this problem. Let’s take a look at the solution:
https://www.lintcode.com/problem/127/description We can follow the steps introduced in https://leetcode-solution.com/breadth-first-search to solve this problem. One thing to note is that, for topological sorting, we do NOT have a variable called visited to record visited nodes while BFS. Why? First of all,… Read More »Lintcode 127 Topological Sorting
In this article I want to talk about Breadth First Search or BFS in short. When to use it and how to use it First of all, when to use BFS? BFS vs DFS Some of the graph related problems… Read More »Breadth First Search(BFS)
https://www.lintcode.com/problem/611/description The idea of this problem is simple, from the source, do a BFS and find the shortest path to hit destination. Let’s take a look at the solution:
https://leetcode.com/problems/word-ladder/description This problem can be solved by BFS for a couple of reasons: Based on our BFS template, at each step(word), we need to find the possible neighbors(next word given only one letter is changed and it’s in the wordList).… Read More »Leetcode 127 Word Ladder
https://leetcode.com/problems/clone-graph/description We can conquer this problem by a couple steps:
https://leetcode.com/problems/word-ladder/description Our idea is simple, for each word, we find all the possible variations by changing only 1 letter and check if the variation is equal to the endWord. The problem is asking us to find the shortest transformation sequence,… Read More »Leetcode 127 Word Ladder
https://leetcode.com/problems/clone-graph There will be 3 steps in the process For the first step we can use BFS Let’s take a look at the solution
https://leetcode.com/problems/number-of-islands/description This is a classic problem that uses BFS as solution. The idea is, we analyze every cell in the grid, if it’s land and we have never visited it before, we find a new island. But we need to… Read More »Leetcode 200 Number of Islands
To address this problem, we can use either Breadth-First Search (BFS) since it’s more suitable for finding the shortest path in an unweighted graph, similar to determining the minimum number of mutations required. The core idea is to represent each… Read More »Leetcode 433 Minimum Genetic Mutation