自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Android消息机制,从Java层到Native层剖析

由Handler、MessageQueue、Looper构成的线程消息通信机制在Android开发中非常常用,不过大部分人都只粗浅地看了Java层的实现,对其中的细节不甚了了,这篇博文将研究Android消息机制从Java层到Native层的实现。消息机制由于更贴近抽象设计,所以整个结构更简单,只包含了消息的产生、分发,不像Input子系统那样还有归类、过滤等环节。整体的结构如下图:Android

2017-10-08 16:37:33 2043

原创 Android App启动流程

前言在使用Android手机时,我们总会启动各种各样的App以满足生活的各种需求,你是否想过,我们是怎样启动这些APP的?今天我将带着读者一起探索在Android系统中,一个App是如何被启动的。在开始分析之前,我们先回想下启动一个App的流程:Android系统桌面->点击应用图标->启动App从这个过程来看,只要弄明白:Android系统桌面是什么点击应用图标后Android系统执行了什么操

2017-02-28 12:34:51 3085

原创 LeetCode题解:Maximum Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray [4,−1,2,1] has the

2016-03-04 09:22:17 571

原创 LeetCode题解:Kth Smallest Element in a BST

Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.Follow up: What if the BST is mod

2016-03-04 09:16:50 622

原创 LeetCode题解:Linked List Cycle

/** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */ pub

2016-03-04 09:02:01 423

原创 LeetCode题解:Maximum Product of Word Lengths

Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case lette

2016-03-01 17:05:58 468

原创 LeetCode题解: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 / 3 return [1,2,3].题意:先序遍历思路:代码:/** * Definition for a

2016-03-01 16:49:40 390

原创 LeetCode题解:Missing Number

Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example, Given nums = [0, 1, 3] return 2.Note: Your algorithm should run in line

2016-03-01 16:48:25 494

原创 LeetCode题解:Bulb Switcher

There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or turning off i

2016-03-01 16:37:47 573

原创 LeetCode题解:Best Time to Buy and Sell Stock with Cooldown

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 (ie, buy one and

2016-03-01 15:51:54 420

原创 LeetCode题解:Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(n).For e

2016-03-01 15:47:31 669

原创 LeetCode题解:Single Number III

Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given nums = [1,

2016-03-01 15:32:49 430

原创 LeetCode题解:Single Number II

Given an array of integers, every element appears three times except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using ex

2016-03-01 15:22:33 390

原创 LeetCode题解: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. top() – Get the

2016-02-29 09:42:08 514

原创 LeetCode题解:First Bad Version

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the

2016-02-29 09:31:00 410

原创 LeetCode题解:Range Sum Query - Immutable

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example: Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1 sumRange(2, 5) -> -1 sumRange(0, 5

2016-02-28 15:17:37 381

原创 LeetCode题解:Binary Tree Paths

Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree:1 / \ 2 3 \ 5 All root-to-leaf paths are:[“1->2->5”, “1->3”]题意:给定二叉树,返回所有路径思路:DFS代码:/** *

2016-02-28 15:03:06 321

原创 LeetCode题解:Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.Example Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6 Return: 1 –> 2 –> 3 –> 4 –> 5题意:移除链表中所有给定值的结点思路:……代码:/** * Definition f

2016-02-28 15:00:35 295

原创 LeetCode题解:Word Pattern

Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.Examples:

2016-02-28 14:56:50 526

原创 LeetCode题解:Bulls and Cows

You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that

2016-02-28 14:47:11 576

原创 LeetCode题解:Isomorphic Strings

Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another chara

2016-02-28 11:05:57 394

原创 LeetCode题解: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 as 00111001011110

2016-02-28 10:44:42 389

原创 LeetCode题解: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 = 2

2016-02-28 10:30:28 338

原创 LeetCode题解:Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints: Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integ

2016-02-28 10:13:40 388

原创 LeetCode题解: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?题意:给定k,返回Pascal 三角形的第k行,要

2016-02-28 10:08:13 572

原创 LeetCode题解: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).题意:层序遍历思路:……代码:/** * Definition for a binary tree node. * public class TreeNode {

2016-02-28 10:05:56 333

原创 LeetCode题解:Remove Element

Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn’t matter what you leave beyond the new length.题意:给定一个数组与

2016-02-28 09:55:07 427

原创 LeetCode题解:Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.题意:将两个有序链表合并得到一个新的有序链表思路:……代码:/** * Definition for singly-l

2016-02-28 09:26:18 651

原创 LeetCode题解:Power of Three

Given an integer, write a function to determine if it is a power of three.Follow up: Could you do it without using any loop / recursion?题意 :给定整数,判断是否为3的幂解题思路:纯计算……代码:public boolean isPowerOfThree(int

2016-02-28 09:19:43 374

原创 LeetCode题解:Ugly Number

Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it in

2016-02-28 09:11:30 344

原创 LeetCode题解:Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in plac

2016-02-27 20:22:20 536

原创 LeetCode题解: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 representation 0000000000000

2016-02-27 20:17:06 468

原创 LeetCode题解:Reverse Linked List

Reverse a singly linked list.题意:反转单链表解题思路:一直取下一个节点作为头部代码:public class Solution { public ListNode reverseList(ListNode head) { return reverseListInt(head,null); } public ListNode reve

2016-02-27 20:12:07 349

原创 LeetCode题解: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 -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> 28 题意:给

2016-02-27 20:06:59 392

原创 LeetCode题解: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-02-27 20:02:09 253

原创 LeetCode题解:Move Zeroes

Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your funct

2016-02-27 20:00:24 339

原创 LeetCode题解: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.题意:给定二叉树,找出最大深度思路:DFSpublic class Solution

2016-02-27 19:52:00 297

原创 LeetCode题解:Nim Game

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the

2016-02-27 19:42:48 674

原创 LeetCode题解:Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up: Can you solve it without using extra space?题意:给定链表,返回环的起点;

2016-02-10 15:56:01 291

原创 LeetCode题解:Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?题意:给定链表,判断是否为环。要求O(1)空间思路:快慢指针,如果存在环,快指针必然遇到慢指针代码:/** * Definition for singly-linked list

2016-02-10 15:22:17 264

图片异步加载

博客 http://blog.csdn.net/u012403246 中剖析Android消息传递机制的Demo

2015-05-24

View事件传递机制Demo源码

View事件传递机制Demo源码,欢迎大家学习

2015-04-17

Android自定义控件:可重用的自定义Dialog类

Android自定义控件:可重用的自定义Dialog类

2015-03-20

Android自定义控件:Android L控件点击水波纹的实现(源码 + Demo)

Android自定义控件:Android L控件点击水波纹的实现(源码 + Demo)

2015-01-18

(源码)Android自定义进度条的4种实现方法

(源码)Android自定义进度条的4种实现方法

2014-11-25

(源码)老版优酷的三级菜单

Android自定义控件:老版优酷的三级菜单(效果图 + Demo)

2014-11-20

空空如也

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

TA关注的人

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