代码改变世界

[LeetCode] 198. House Robber _Easy tag: Dynamic Programming

2018-07-17 05:10 by Johnson_强生仔仔, 268 阅读, 0 推荐, 收藏, 编辑
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文

[LeetCode] questions conclustion_BFS, DFS

2018-07-17 01:37 by Johnson_强生仔仔, 536 阅读, 0 推荐, 收藏, 编辑
摘要:BFS, DFS 的题目总结. Directed graph: Directed Graph Loop detection and if not have, path to print all path. Morris Traversal_ O(1) space to change binary t 阅读全文

[LeetCode] 113. Path Sum II

2018-07-14 00:49 by Johnson_强生仔仔, 292 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Exampl 阅读全文

[LeetCode] 257. Binary Tree Paths_ Easy tag: DFS

2018-07-13 23:42 by Johnson_强生仔仔, 265 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example: 3.2) Recursive 4.. Test cases 1) empty 2) 1 3) 阅读全文

[LeetCode] 116&117. Populating Next Right Pointers in Each Node I&II_Medium tag: BFS(Dont know why leetcode tag it as DFS...)

2018-07-13 07:33 by Johnson_强生仔仔, 218 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its ne 阅读全文

[LeetCode] 114. Flatten Binary Tree to Linked List_Medium tag: DFS

2018-07-13 07:09 by Johnson_强生仔仔, 197 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look 阅读全文

[LeetCode] 112. Path Sum_Easy tag: DFS

2018-07-13 06:16 by Johnson_强生仔仔, 230 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. N 阅读全文

[LeetCode] 851. Loud and Rich_ Medium tag: DFS

2018-07-13 04:55 by Johnson_强生仔仔, 397 阅读, 0 推荐, 收藏, 编辑
摘要:In a group of N people (labelled 0, 1, 2, ..., N-1), each person has different amounts of money, and different levels of quietness. For convenience, w 阅读全文

[LeetCode] 711. Number of Distinct Islands II_hard tag: DFS

2018-07-12 05:23 by Johnson_强生仔仔, 979 阅读, 0 推荐, 收藏, 编辑
摘要:Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) Yo 阅读全文

[LeetCode] 694. Number of Distinct Islands

2018-07-11 06:17 by Johnson_强生仔仔, 576 阅读, 0 推荐, 收藏, 编辑
摘要:Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) Yo 阅读全文