### 题意 Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: 编写一个高效的算法来判断 m x n 矩阵中,是否存在一个目标值。该矩阵具有如下特性: - Integers in each row are sorted from left to right. - 每行中的整数从左到右按升序排列...
阅读全文>>2020年11月7日 16:28 作者:nancy 分类:[LeetCode] 1533
### 题意 Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). 给定一个二叉树,返回其节点值自底向上的层次遍历。 (即按从叶子节点所在层到根节点所在的层,逐层从左向右遍历) For example: Given binary tre...
阅读全文>>2018年5月29日 10:24 作者:nancy 分类:[LeetCode] 1405
### 题意 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"] ...
阅读全文>>2018年5月25日 12:15 作者:nancy 分类:[LeetCode] 1431
### 题意 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...
阅读全文>>2018年5月25日 09:17 作者:nancy 分类:[LeetCode] 1420
### 题意 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 leaf is a nod...
阅读全文>>2018年5月24日 10:20 作者:nancy 分类:[LeetCode] 1371
### 题意 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 every nod...
阅读全文>>2018年5月24日 09:57 作者:nancy 分类:[LeetCode] 1327
### 题意 Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 将一个按照升序排列的有序数组,转换为一棵高度平衡二叉搜索树。 For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the tw...
阅读全文>>2018年5月23日 10:01 作者:nancy 分类:[LeetCode] 1366
### 题意 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 leaf is a nod...
阅读全文>>2018年5月23日 09:44 作者:nancy 分类:[LeetCode] 1361
### 题意 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,3,4,4,3] 是对称的。 ``` 1 / \ 2 ...
阅读全文>>2018年5月22日 10:35 作者:nancy 分类:[LeetCode] 1359
### 题意 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. 如果两个树在结构上相同,并且节...
阅读全文>>2018年5月22日 09:45 作者:nancy 分类:[LeetCode] 1454
你还没有登录,请 或者