- 博客(24)
- 资源 (4)
- 收藏
- 关注
原创 leetcodeOJ 110. 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 every node never differ
2017-03-29 14:55:18 170
原创 leetcodeOJ 109. Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.代码如下:/** * Definition for singly-linked list. * struct ListNode { * int val; *
2017-03-29 14:23:31 170
原创 leetcodeOJ 108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:寻找中间节点/** * Definition for a binary tree node. * struct TreeNode { * int val; * Tree
2017-03-29 14:21:22 124
原创 leetcodeOJ 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 / \ / \3 4 4 3
2017-03-29 12:41:41 187
原创 leetcodeOJ 103. Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tr
2017-03-29 11:21:47 202
原创 leetcodeOJ 106. Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.代码如下:/** * Definition for a binary tree node. * st
2017-03-29 10:51:21 174
原创 leetcodeOJ 102. 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,null,15,7], 3 / \ 9 20
2017-03-29 10:31:02 165
原创 leetcodeOJ 107. Binary Tree Level Order Traversal II
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 tree [3,9,20,null,null,15,
2017-03-29 10:27:05 179
原创 leetcodeOJ 105. Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.使用的是递归的方法。代码如下:/** * Definition for a binary tree
2017-03-29 09:33:59 153
原创 leetcodeOJ 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.最小深度问题,注意引用传递。代码如下:/** *
2017-03-27 15:54:22 208
原创 leetcodeOJ 104. 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.最大深度问题/** * Definition for a binary
2017-03-27 15:48:18 400
原创 leetcodeOJ 113. Path Sum II
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 = 22, 5 / \
2017-03-27 15:17:34 204
原创 leetcodeOJ 112. 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.For example:Given the below binary tree and sum
2017-03-27 14:39:03 331
原创 leetcodeOJ 129. Sum Root to Leaf Numbers
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 which represents the number 123.Find the total
2017-03-27 14:23:16 237
原创 leetcodeOJ 94. Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].非递归方法。/** * Definitio
2017-03-27 13:27:01 175
原创 leetcodeOJ 144. Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].非递归方法。/** * Definition for
2017-03-27 13:25:05 163
原创 leetcodeOJ 145. Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].非递归方法,/** * Definition for
2017-03-27 13:23:25 154
原创 leetcodeOJ 34. Search for a Range
Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the targ
2017-03-25 16:16:07 260
原创 leetcodeOJ 240. Search a 2D Matrix II
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in ea
2017-03-25 16:12:06 194
原创 leetcodeOJ 74. Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each r
2017-03-25 15:20:42 221
原创 leetcodeOJ 6. ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I
2017-03-25 10:14:49 164
转载 转载:史上最全常用正则表达式
转载自:http://www.cnblogs.com/zxin/archive/2013/01/26/2877765.html一、校验数字的表达式1. 数字:^[0-9]*$2. n位的数字:^\d{n}$3. 至少n位的数字:^\d{n,}$4. m-n位的数字:^\d{m,n}$5. 零和非零开头的数字:^(0|[1-9][0-9
2017-03-18 15:53:55 457
原创 名企笔试:好未来2017秋招笔试:(倒置字符串)
题目来源:http://mp.weixin.qq.com/s/9enaEDFYN__BIbmKNrDOeQ将一句话的单词进行倒置,标点不倒置。比如 I like beijing. 经过函数后变为:beijing. like I输入描述:每个测试输入包含1个测试用例: I like beijing. 输入用例长度不超过100
2017-03-08 15:54:01 1431
原创 名企笔试:好未来2017秋招笔试(连续最长的数字串)
题目来源:http://mp.weixin.qq.com/s/4YbEmh_oHjsY2EQyrpwANw读入一个字符串str,输出字符串str中的连续最长的数字串输入描述:测试输入包含1个测试用例,一个字符串str,长度不超过255。输出描述:在一行内输出str中里连续最长的数字串。输入例子:abcd12345ed1
2017-03-08 15:35:54 988
设计模式之禅
2015-04-23
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人