
LeetCode — dfs
ZQYnn~
这个人很神秘,什么都没有写~
展开
-
LeetCode 101. Symmetric Tree
101. Symmetric TreeGiven 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 symmetric: 1 / \ 2 2 /...原创 2019-09-13 12:05:00 · 119 阅读 · 0 评论 -
LeetCode 51. N-Queens
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.Each s...原创 2019-07-21 17:53:42 · 157 阅读 · 0 评论 -
LeetCode 344.Reverse String
Reverse StringWrite a function that reverses a string. The input string is given as an array of characters char[].Do not allocate extra space for another array, you must do this by modifying the inp...原创 2019-09-14 11:00:54 · 103 阅读 · 0 评论 -
LeetCode 230.Kth Smallest Element in a BST
Kth Smallest Element in a BSTGiven a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.Ex...原创 2019-09-14 10:48:28 · 153 阅读 · 0 评论 -
LeetCode 98. Validate Binary Search Tree
Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys l...原创 2019-09-14 10:43:50 · 94 阅读 · 0 评论 -
LeetCode 104 .Maximum Depth of Binary Tree
Maximum Depth of Binary TreeGiven 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 leaf node.Note: A ...原创 2019-09-14 10:34:57 · 170 阅读 · 0 评论 -
LeetCode 94.Binary Tree Inorder Traversal
Binary Tree Inorder TraversalGiven a binary tree, return the inorder traversal of its nodes’ values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,3,2]Follow up: Recursive...原创 2019-09-14 10:27:44 · 173 阅读 · 0 评论 -
LeetCode 110. Balanced Binary Tree
Balanced Binary TreeGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of...原创 2019-09-14 09:31:25 · 131 阅读 · 0 评论 -
LeetCode 257. Binary Tree Paths
Binary Tree PathsGiven a binary tree, return all root-to-leaf paths.Note: A leaf is a node with no children.Example:Input: 1 / \2 3 \ 5Output: ["1->2->5", "1->3"]Expl...原创 2019-09-14 09:14:07 · 109 阅读 · 0 评论 -
LeetCode 100. Same Tree
Same TreeGiven 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 identical and the nodes have the same value....原创 2019-09-13 15:18:52 · 123 阅读 · 0 评论 -
LeetCode 111. Minimum Depth of Binary Tree
Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note: A ...原创 2019-09-13 15:11:35 · 127 阅读 · 0 评论 -
LeetCode 515. Find Largest Value in Each Tree Row
Find Largest Value in Each Tree RowExample:Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9]You need to find the largest value in each row of a b...原创 2019-09-13 14:45:45 · 118 阅读 · 0 评论 -
LeetCode 513. Find Bottom Left Tree Value
Find Bottom Left Tree ValueGiven a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output:1Example 2:Input: 1 / \ ...原创 2019-09-13 12:53:00 · 170 阅读 · 0 评论 -
LeetCode 199.Binary Tree Right Side View
Binary Tree Right Side ViewGiven a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.Example:Input: [1,2,3,nul...原创 2019-09-13 12:40:08 · 260 阅读 · 0 评论 -
LeetCode 200. Number of Islands
Number of IslandsGiven a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertic...原创 2019-09-13 12:31:16 · 196 阅读 · 0 评论 -
LeetCode 112. Path Sum
Path SumGiven 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.Note: A leaf is a node with no children....原创 2019-09-13 12:17:36 · 91 阅读 · 0 评论 -
LeetCode 102. Binary Tree Level Order Traversal
Binary Tree Level Order TraversalGiven a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,nul...原创 2019-09-13 12:10:00 · 100 阅读 · 0 评论 -
LeetCode 37. Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells.A sudoku solution must satisfy all of the following rules:Each of the digits 1-9 must occur exactly once in each row.Each of the...原创 2019-07-17 23:31:55 · 135 阅读 · 0 评论