LeetCode — dfs
ZQYnn~
这个人很神秘,什么都没有写~
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 101. Symmetric Tree
101. Symmetric Tree 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 symmetric: 1 / \ 2 2 /...原创 2019-09-13 12:05:00 · 122 阅读 · 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 · 161 阅读 · 0 评论 -
LeetCode 344.Reverse String
Reverse String Write 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 · 114 阅读 · 0 评论 -
LeetCode 230.Kth Smallest Element in a BST
Kth Smallest Element in a BST Given 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 · 161 阅读 · 0 评论 -
LeetCode 98. Validate Binary Search Tree
Validate Binary Search Tree Given 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 · 102 阅读 · 0 评论 -
LeetCode 104 .Maximum Depth of Binary Tree
Maximum Depth of Binary Tree 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 leaf node. Note: A ...原创 2019-09-14 10:34:57 · 178 阅读 · 0 评论 -
LeetCode 94.Binary Tree Inorder Traversal
Binary Tree Inorder Traversal Given a binary tree, return the inorder traversal of its nodes’ values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [1,3,2] Follow up: Recursive...原创 2019-09-14 10:27:44 · 179 阅读 · 0 评论 -
LeetCode 110. Balanced Binary Tree
Balanced Binary Tree Given 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 · 136 阅读 · 0 评论 -
LeetCode 257. Binary Tree Paths
Binary Tree Paths Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example: Input: 1 / \ 2 3 \ 5 Output: ["1->2->5", "1->3"] Expl...原创 2019-09-14 09:14:07 · 116 阅读 · 0 评论 -
LeetCode 100. Same Tree
Same Tree 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 identical and the nodes have the same value....原创 2019-09-13 15:18:52 · 127 阅读 · 0 评论 -
LeetCode 111. Minimum Depth of Binary Tree
Minimum Depth of Binary Tree Given 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 · 134 阅读 · 0 评论 -
LeetCode 515. Find Largest Value in Each Tree Row
Find Largest Value in Each Tree Row Example: 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 · 128 阅读 · 0 评论 -
LeetCode 513. Find Bottom Left Tree Value
Find Bottom Left Tree Value 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 / \ ...原创 2019-09-13 12:53:00 · 180 阅读 · 0 评论 -
LeetCode 199.Binary Tree Right Side View
Binary Tree Right Side View Given 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 · 268 阅读 · 0 评论 -
LeetCode 200. Number of Islands
Number of Islands Given 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 · 206 阅读 · 0 评论 -
LeetCode 112. Path Sum
Path Sum 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. Note: A leaf is a node with no children....原创 2019-09-13 12:17:36 · 102 阅读 · 0 评论 -
LeetCode 102. Binary Tree Level Order Traversal
Binary Tree Level Order Traversal Given 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 · 108 阅读 · 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 · 144 阅读 · 0 评论
分享