随笔分类 - leetcode_dfs
摘要:原文链接:https://blog.csdn.net/weixin_43314519/article/details/107955117 给定一个非空二叉树,返回其最大路径和。 本题中,路径被定义为一条从树中任意节点出发,达到任意节点的序列。该路径至少包含一个节点,且不一定经过根节点。 class
阅读全文
摘要: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 t
阅读全文
摘要:Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example 1: Input:
阅读全文
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 题目含义:给定一个升序的列表,构造一个平衡二叉树 平衡二叉树:二叉排序树集中了数
阅读全文
摘要: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 adjacen
阅读全文
摘要:Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing su
阅读全文
摘要:Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is b
阅读全文
摘要:There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct
阅读全文
摘要:Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are:
阅读全文
摘要:You are given a data structure of employee information, which includes the employee's unique id, his importance value and his directsubordinates' id.
阅读全文
摘要: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
阅读全文
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Given the below binary tree and sum
阅读全文
摘要:Given a binary tree, flatten it to a linked list in-place. For example,Given The flattened tree should look like: 方法二:
阅读全文
摘要:Given a binary tree Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL
阅读全文
摘要:Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution sti
阅读全文
摘要:You need to find the largest value in each row of a binary tree. Example: 方法二:
阅读全文
摘要: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. For exa
阅读全文
摘要:The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each hou
阅读全文
摘要:Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Example 2:
阅读全文
摘要: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
阅读全文