自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

斗code、年华

停下休息的时候不要忘记别人还在奔跑。

  • 博客(180)
  • 收藏
  • 关注

原创 【leetcode】【198】House Robber

一、问题描述You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that ad

2016-03-15 15:53:09 210

原创 【leetcode】【191】Number of 1 Bits

一、问题描述Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary represent

2016-03-15 15:43:56 265

原创 【leetcode】【190】Reverse Bits

一、问题描述Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary

2016-03-15 15:40:44 226

原创 【leetcode】【189】Rotate Array

一、问题描述Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].二、问题分析题目有好几种解决方案。如果没有空间要求,可以另开一个数

2016-03-15 15:32:54 219

原创 【leetcode】【173】Binary Search Tree Iterator

一、问题描述Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.

2016-03-15 15:25:59 264

原创 常见排序算法的Java实现

一、常见的排序算法常见的排序包括:插入类(简单插入、希尔排序)、选择类(选择排序、堆排序)、交换类(冒泡排序、快速排序)等,当然还有其它的比如归并排序、桶排序、计数排序等等。二、Java实现package com.xiaoliu;public class Sort { /** * 泡在前,依次将第i个与i之后的所有元素进行比较 ,时间复杂度O(n2),稳定排序 *

2016-03-13 10:55:36 363

原创 【leetcode】【172】Factorial Trailing Zeroes

一、问题描述Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.二、问题分析先读明白题意,求n!的尾部0的个数;这其实是一道数学题对n!做质因数分解n!=2x*3y*5z*

2016-03-08 11:21:43 272

原创 【leetcode】【171】Excel Sheet Column Number

一、问题描述Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3

2016-03-08 11:08:23 213

原创 【leetcode】【169】Majority Element

一、问题描述Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the major

2016-03-08 11:05:02 221

原创 【leetcode】【168】Excel Sheet Column Title

一、问题描述Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB

2016-03-08 10:56:26 253

原创 【leetcode】【165】Compare Version Numbers

一、问题描述Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-

2016-03-08 10:47:45 236

原创 【leetcode】【160】Intersection of Two Linked Lists

一、问题描述Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘

2016-03-08 10:38:32 233

原创 【leetcode】【155】Min Stack

一、问题描述Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.t

2016-03-08 10:23:46 411

原创 【leetcode】【153】Find Minimum in Rotated Sorted Array

一、问题描述Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicat

2016-03-08 10:05:37 257

原创 【leetcode】【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].Note: Rec

2016-03-08 09:56:38 317

原创 【leetcode】【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].Note: Recu

2016-03-08 09:35:20 240

原创 【leetcode】【136】Single Number

一、问题描述Given an array of integers, every element appears twice except for one. Find that single one.二、问题分析位操作类题目。充分利用XOR操作的特点。三、Java AC代码public int singleNumber(int[] nums) { int

2016-03-07 11:11:33 234

原创 【leetcode】【125】Valid Palindrome

一、问题描述Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a ca

2016-03-07 11:02:01 459

原创 【leetcode】【122】Best Time to Buy and Sell Stock II

一、问题描述Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like

2016-03-07 10:53:51 243

原创 【leetcode】【121】Best Time to Buy and Sell Stock

一、问题描述Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of

2016-03-07 10:45:31 275

原创 【leetcode】【119】Pascal's Triangle II

一、问题描述Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?二、

2016-03-07 10:37:59 234

原创 【leetcode】【118】Pascal's Triangle

一、问题描述Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]二、问题分析杨辉三角问题,比

2016-03-07 10:28:34 245

原创 【leetcode】【116】Populating Next Right Pointers in Each Node

一、问题描述Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next

2016-03-07 10:22:51 255

原创 【leetcode】【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 t

2016-03-07 10:09:10 219

转载 【郭神】 Android Context完全解析,你所不知道的Context的各种细节

转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/47028975前几篇文章,我也是费劲心思写了一个ListView系列的三部曲,虽然在内容上可以说是绝对的精华,但是很多朋友都表示看不懂。好吧,这个系列不仅是把大家给难倒了,也确实是把我给难倒了,之前为了写瀑布流ListView的Demo就写了大半个月的时间。那么本篇文章我们就

2016-03-07 10:00:58 608

转载 【Android学习笔记】Android中pendingIntent的深入理解

转自:http://blog.csdn.net/yuzhiboyi/article/details/8484771pendingIntent字面意义:等待的,未决定的Intent。要得到一个pendingIntent对象,使用方法类的静态方法 getActivity(Context, int, Intent, int),getBroadcast(Context, int, Inte

2016-03-04 15:03:23 363

原创 【leetcode】【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

2016-03-04 11:25:48 219

原创 【leetcode】【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.二、问题分析Binary Search Tree的定义,BST的中序遍历恰好是sorted in ascending order。但是创建树的时候采用的先序的方式结合二分查找。

2016-03-04 11:21:00 223

原创 【leetcode】【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

2016-03-04 11:07:21 230

原创 【leetcode】【106】Construct Binary Tree from Inorder and Postorder Traversal

一、问题描述Given inorder and postorder traversal of a tree, construct the binary tree.二、问题分析同上一题差不多,首先中序和后序是可以确定唯一一棵树的。这道题跟pre+in一样的方法做,只不过找左子树右子树的位置不同而已。   1

2016-03-04 11:01:53 271

原创 【leetcode】【105】Construct Binary Tree from Preorder and Inorder Traversal

一、问题描述Given preorder and inorder traversal of a tree, construct the binary tree.二、问题分析首先先序和中序是可以确定唯一的一棵树的。 1 / \ 2 3 / \ / \ 4 5 6 7对于上图的树来说, index

2016-03-04 10:56:42 351

原创 【leetcode】【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,#,#,15,7}, 3 / \

2016-03-04 10:48:06 226

原创 【leetcode】【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 is symmetric: 1 / \ 2 2 / \ / \3 4 4 3

2016-03-04 10:38:29 257

原创 【leetcode】【100】Same Tree

一、问题描述Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.

2016-03-04 10:28:09 250

原创 【leetcode】【94】Binary Tree Inorder Traversal

一、问题描述Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Note: Recur

2016-03-04 10:15:15 210

原创 【leetcode】【91】Decode Ways

一、问题描述A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine th

2016-03-04 09:54:57 246

原创 【leetcode】【90】Subsets II

一、问题描述Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must no

2016-03-03 11:36:50 210

原创 【leetcode】【88】Merge Sorted Array

一、问题描述Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) t

2016-03-03 11:20:53 270

原创 【leetcode】【86】Partition List

一、问题描述Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the node

2016-03-03 11:16:44 1128

原创 【leetcode】【82】Remove Duplicates from Sorted List II

一、问题描述Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.

2016-03-03 11:02:36 338

空空如也

空空如也

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

TA关注的人

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