1 Cubic Meter

一立方米

[LeetCode] 111. 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 leaf is a node with no children. Example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its minimum depth = 2. 解题报告 思路 反正就是,有叶子就往下找,没叶子就完事儿了嘛~ 方法一:递归 在处理一颗树的时候递归往往是很容易想到的方法,对于每个节点只要检查左

[LeetCode] 207. Course Schedule

发布于 # 解题报告

题目 LeetCode 链接 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 to first take course 1, which is expressed as a pair: [0,1] Given the total number of courses and a list of prerequisite pairs, is it possible for you to finish all courses? Example 1: Input: 2, [[1,0]] Output: true Explanation: There are

[TopCoder-SRM 726] Unpacking

发布于 # 解题报告

题目 TopCoder链接 Problem Statement The holidays are near. Hero would like to buy some candies, so he went to the store. In the store he found some boxes. Each box has a label with three positive integers a[i], b[i], and cost[i]. Their meaning is as follows: Obviously, cost[i] is the amount Hero has to pay to buy this box. The other two numbers promise that the box will contain exactly a[i] red candie

[LeetCode] 3. Longest Substring Without Repeating Characters

发布于 # 解题报告

题目 LeetCode链接 Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of 1. Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substring, "pwke" is a subsequenceand not a substring. 解题报告 思路 乍一想可能是动态规划的一道题,实际上

[LeetCode] 2. Add Two Numbers

发布于 # 解题报告

题目 LeetCode链接 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Example Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0