代码改变世界

[LeetCode] 1. Two Sum_Easy tag: Hash Table

2018-08-10 12:16 by Johnson_强生仔仔, 259 阅读, 0 推荐, 收藏, 编辑
摘要:Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文

[LeetCode] 559. Maximum Depth of N-ary Tree_Easy tag: DFS

2018-08-09 09:00 by Johnson_强生仔仔, 266 阅读, 0 推荐, 收藏, 编辑
摘要:Given a n-ary 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 le 阅读全文

[LeetCode] 310. Minimum Height Trees_Medium tag: BFS

2018-08-09 04:31 by Johnson_强生仔仔, 180 阅读, 0 推荐, 收藏, 编辑
摘要:For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible roote 阅读全文

[LeetCode] 787. Cheapest Flights Within K Stops_Medium tag: Dynamic Programming, BFS, Heap

2018-08-09 00:00 by Johnson_强生仔仔, 260 阅读, 0 推荐, 收藏, 编辑
摘要:There are n cities connected by m flights. Each fight starts from city u and arrives at v with a price w. Now given all the cities and fights, togethe 阅读全文

[LeetCode] 490. The Maze_Medium tag: BFS/DFS

2018-08-08 04:34 by Johnson_强生仔仔, 353 阅读, 0 推荐, 收藏, 编辑
摘要:There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop roll 阅读全文

[LeetCode] 129. Sum Root to Leaf Numbers_Medium tag: DFS

2018-08-08 00:40 by Johnson_强生仔仔, 281 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 whic 阅读全文

[LeetCode] 78. Subsets tag: backtracking

2018-08-08 00:26 by Johnson_强生仔仔, 267 阅读, 0 推荐, 收藏, 编辑
摘要:Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Exampl 阅读全文

[LeetCode] 130. Surrounded Regions_Medium tag: DFS/BFS

2018-08-08 00:09 by Johnson_强生仔仔, 244 阅读, 0 推荐, 收藏, 编辑
摘要:Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in 阅读全文

[LeetCode] 99. Recover Binary Search Tree_Hard_Inorder traversal

2018-08-07 23:37 by Johnson_强生仔仔, 198 阅读, 0 推荐, 收藏, 编辑
摘要:Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Example 1: Input: [1,3,null,null,2 阅读全文

[LeetCode] 100. Same Tree_Easy tag: DFS

2018-08-07 04:31 by Johnson_强生仔仔, 186 阅读, 0 推荐, 收藏, 编辑
摘要:Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally ident 阅读全文
上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 39 下一页