代码改变世界

[LeetCode] 827. Making A Large Island

2018-07-10 05:33 by Johnson_强生仔仔, 525 阅读, 0 推荐, 收藏, 编辑
摘要:In a 2D grid of 0s and 1s, we change at most one 0 to a 1. After, what is the size of the largest island? (An island is a 4-directionally connected gr 阅读全文

[LeetCode] 104. Maximum Depth of Binary Tree_Easy tag: DFS

2018-07-09 23:31 by Johnson_强生仔仔, 180 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l 阅读全文

[LeetCode] 301. Remove Invalid Parentheses_Hard tag:BFS

2018-07-09 10:40 by Johnson_强生仔仔, 388 阅读, 0 推荐, 收藏, 编辑
摘要:Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may cont 阅读全文

[LeetCode] 210. Course Schedule II

2018-07-08 10:46 by Johnson_强生仔仔, 290 阅读, 0 推荐, 收藏, 编辑
摘要: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 阅读全文

Directed Graph Loop detection and if not have, path to print all path.

2018-07-08 10:46 by Johnson_强生仔仔, 428 阅读, 0 推荐, 收藏, 编辑
摘要:这里总结针对一个并不一定所有点都连通的general directed graph, 去判断graph里面是否有loop存在, 收到启发是因为做了[LeetCode] 207 Course Schedule_Medium tag: BFS, DFS, 这个题实际上就是监测directed graph 阅读全文

[LeetCode] 785. Is Graph Bipartite?_Medium tag: DFS, BFS

2018-07-06 09:25 by Johnson_强生仔仔, 414 阅读, 0 推荐, 收藏, 编辑
摘要:Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipartite if we can split it's set of nodes into two ind 阅读全文

[LeetCode] 286. Walls and Gates_Medium tag: BFS

2018-07-06 06:19 by Johnson_强生仔仔, 243 阅读, 0 推荐, 收藏, 编辑
摘要:You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or an obstacle. 0 - A gate. INF - Infinity means an empty room 阅读全文

[LeetCode] 261. Graph Valid Tree _ Medium tag: BFS

2018-07-06 04:30 by Johnson_强生仔仔, 315 阅读, 0 推荐, 收藏, 编辑
摘要:Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make 阅读全文

[LeetCode] 513. Find Bottom Left Tree Value_ Medium tag: BFS

2018-07-06 01:00 by Johnson_强生仔仔, 244 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 / \ 1 3 Output: 1 Example 2: Input: 1 / \ 2 3 / / \ 4 5 阅读全文

[LeetCode] 101. Symmetric Tree_ Easy tag: BFS

2018-07-06 00:31 by Johnson_强生仔仔, 248 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文