Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example: Input:[[ 1, 2, 3 ],[ 4, 5, 6 ],[ 7, 8, 9 ]]Output:
Tree的traverse,Preorder, Inorder, Postorder ,这些都是用stack来模拟考察的比较多。参考这里: PreOrder, InOrder, PostOrder 题型总结 这里主要总结,divide and conquer 逻辑,往上返回result的情况; Lowest Common Ancestor of a Binary Search Tree 思路
====BFS 找联通量,找component. Number of Islands (BFS, DFS 都可以做) Surrounded Regions 算法是:先收集四个周边的 O,然后用BFS或者DFS向里面扩展,visited记录connect点,最后如果没有被visited到的O,会变成X;T: O(m*n), Space: O(m*n). Is Graph Bipartite (