leetcode bfs
proudmore
这个作者很懒,什么都没留下…
展开
-
Leetcode Word ladder I, II
public class Solution { HashMap<String, Integer> distance; public int ladderLength(String start, String end, Set<String> dict) { if(start.equals(end))return 1; distance=new Hash原创 2015-03-14 08:10:04 · 155 阅读 · 0 评论 -
Leetcode Surrounded regions
Given a 2D board containing ‘X’ and ‘O’, capture all regions surrounded by ‘X’.A region is captured by flipping all ‘O’s into ‘X’s in that surrounded region. For example, X X X X X O O X X X原创 2015-03-18 13:46:10 · 196 阅读 · 0 评论 -
Leetcode Number of islands
Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume原创 2015-05-08 02:55:23 · 145 阅读 · 0 评论 -
Leetcode Course Schedule I, II
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair:原创 2015-05-08 07:27:04 · 242 阅读 · 0 评论