今際の国の呵呵君
Saturday, November 4, 2017
[LeetCode]Pacific Atlantic Water Flow
BFS的问题,我们只需要分别从上左和下右开始BFS,分别维护两个matrix来记录visited过的cell,找到公共可以到达的cell即可。假设输入矩阵为m * n,时间复杂度O(m * n),空间复杂度O(m * n),代码如下:
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment