Tag Archives: DFS

01 Matrix
Leave a commentJune 20, 2017 by oneOokay
Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. The distance …
Continue reading 
Generate Parentheses
Leave a commentMay 14, 2017 by oneOokay
Given n pairs of parentheses, write a function to generate all combinations of wellformed parentheses. For example, given n = …
Continue reading 
Longest Increasing Path in a Matrix
Leave a commentDecember 19, 2016 by oneOokay
Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to …
Continue reading 
Course Schedule I II
Leave a commentDecember 19, 2016 by oneOokay
There are a total of n courses you have to take, labeled from 0 to n – 1. Some courses …
Continue reading 
Topological Sorting Related
Leave a commentDecember 18, 2016 by oneOokay
拓扑排序以及相关题目： 拓扑排序 For each directed edge A > B in graph, A must before B in the order list. The …
Continue reading 
Sudoku Solver
Leave a commentDecember 17, 2016 by oneOokay
典型的DFS。boolean solve(char[][] board):DFS recursive的函数返回可以是void，TreeNode和boolean 了。(还有之后的List和ArrayList) public void solveSudoku(char[][] board) { solve(board); } private boolean solve(char[][] board){ //recursive method for (int …
Continue reading 
Largest BST Subtree
Leave a commentDecember 1, 2016 by oneOokay
Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with …
Continue reading