自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(6)
  • 收藏
  • 关注

原创 二维数组中的查找

剑指Offer  面试题3, P38 题意:有这样一个二维数组,每一行从左到右递增,每一列从上到下递增。给出这样一个数组和数字,判断这个数字是否在这个数组中。 分析: 这个题最重要的是找出规律,因为是每行排好序的,可以对每一行用二分查找,这样复杂度是O(NlonN),这里就没用到每一列也是递增的。 通过分析,可以有这样的规律: 1.从右上角看,这个元素是这一行最大的,同

2015-09-20 15:48:45 215 1

原创 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 diffe

2015-08-22 22:28:42 208

原创 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. 求二叉树的最大深度。 思路:求每个节点的左子树深度和有子树深度

2015-08-22 22:06:56 183

原创 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. 思路:分别求出左右节点的最小深度,然后返回其中一个较小的深度。

2015-08-22 21:54:19 171

原创 Reverse Linked List

Reverse a singly linked list. 反转单链表。 思路:每次将当前节点变为当前节点的next,将next节点变为当前节点。/**  * Definition for singly-linked list.  * public class ListNode {  *     int val;  *     ListNode next;  *     ListNo

2015-08-20 22:00:29 190

原创 Reverse Linked List II

Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, n satisfy t

2015-08-20 21:50:44 196

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除