自定义博客皮肤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)
  • 收藏
  • 关注

原创 LeetCode题解:Factorial Trailing Zeroes

Given an integer n, return the number of trailing zeroes in n!.题意:求n阶乘结果中有多少0解决思路:阶乘要出现0必然能分解为5*2,2的数量大于5的数量,所以每一个5必然有一个2匹配,所以计算5的个数即可代码:public class Solution { public int trailingZeroes(int n) {

2015-08-26 20:39:56 457

原创 LeetCode题解: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].题意:将数组内元素向右移动k步解决思路:当前位置+k除以数组长度的余数为新的位置代码:public class

2015-08-26 20:37:35 556

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

2015-08-26 20:35:16 429

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

2015-08-26 20:27:20 422

原创 LeetCode题解: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 adjacent houses

2015-08-26 20:25:47 581

原创 LeetCode题解:Count Primes

Count the number of prime numbers less than a non-negative number, n.题意:计算质数数量解决思路:按照质数性质求代码:public class Solution { public int countPrimes(int n) { boolean notPrime[] = new boolean[n + 2]; n

2015-08-26 20:19:18 505

原创 LeetCode题解:Happy Number

Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of i

2015-08-26 20:17:58 1224

原创 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题意:删除链表中某个节点解决思路:……代码:public class Solution

2015-08-26 20:04:02 429

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

2015-08-26 19:53:46 902

原创 LeetCode题解:Reverse Linked List

Reverse a singly linked list.题意:逆转单向链表解决思路:依次取得后一个节点,再改变指针指向就可以了代码:public class Solution { public ListNode reverseList(ListNode head) { return reverseListInt(head,null); } public Lis

2015-08-26 19:48:27 383

原创 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 题意:与

2015-08-26 19:42:46 460

原创 LeetCode题解:Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example:1 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB 题意:给定一个整数,按照给定的对应关系返回列标题解决思路:用一个大小为26的数组代表每个数

2015-08-26 19:40:26 475

原创 LeetCode题解:Lowest Common Ancestor of a Binary Search Tree

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two

2015-08-22 08:34:36 564

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

2015-08-21 15:29:51 315

原创 LeetCode题解:Implement strStr()

Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.题意:求needle代表的字符串在haystack字符串中第一次出现的位置解决思路:传统字符串匹配算法KMP代码:public class Solu

2015-08-21 15:16:10 477

原创 LeetCode题解:Valid Sudoku

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’.A partially filled sudoku which

2015-08-21 15:14:36 474

原创 LeetCode题解:Plus One

Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.题意:用一个数组代表一个非负整数,求该数+1后的值解决思路

2015-08-21 15:00:18 389

原创 LeetCode题解:Add Binary

Given two binary strings, return their sum (also a binary string).For example, a = “11” b = “1” Return “100”.题意:给定两个二进制数,求其和解决思路:把二进制数转换为整数,求和后转换为二进制字符串按照二进制运算规则直接得结果代码:public class Solution {

2015-08-21 14:58:07 520

原创 LeetCode题解:Valid Parentheses

Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.The brackets must close in the correct order, “()” and “()[]{}” are all valid but “

2015-08-21 10:36:12 353

原创 LeetCode题解: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 N A P L S I I G

2015-08-21 09:53:36 375

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

2015-08-21 09:53:15 331

原创 LeetCode题解:String to Integer (atoi)

Implement atoi to convert a string to an integer.题意:把字符串转换为整数解决思路:按照整数的限制一个个转换字符串的每一个字符代码:public class Solution { public int myAtoi(String str) { int sign = 1; int total = 0;

2015-08-21 09:52:58 391

原创 LeetCode题解:Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.题意:判断一个整数是否为回文解决思路:按照回文的特征,把整数倒过来,如果倒过来的数和原整数相同,则为回文数字代码:public class Solution { public boolean isPalindrome(int x) {

2015-08-21 09:52:34 384

原创 LeetCode题解:Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, r

2015-08-21 09:52:15 437

原创 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"] 题意:给定一颗二叉树,返回所有从根节点到叶

2015-08-21 09:51:57 433

原创 LeetCode题解:Roman to Integer

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.题意:给定一个1-3999范围内的罗马数字,把它转换为整数解决思路:按照罗马数字转换代码:public class Solution { public int romanToInt(

2015-08-21 09:51:38 443

原创 LeetCode题解:Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.题意:找出字符串数组中最长的共有前缀解决思路:遍历所有字符串从头到尾找共有前缀代码:public class Solution { public String longestCommonPrefix(String[] st

2015-08-21 09:51:18 860

原创 LeetCode题解:Remove Nth Node From End of List

LeetCode

2015-08-21 09:50:35 520

原创 从设计到实现,一步步教你实现Android-Universal-ImageLoader-辅助类

通过前面几篇博文,我们分析了 AUI 的缓存、工具类、显示与加载这几个方面的代码,今天呢,我们继续研究 AUI 的源码,学习其中的核心辅助工具类。希望大家能在里面学到东西哈。Download要下载一张图片,我们想象需要什么哈:首先我们得设定支持的协议,得有下载的链接,由相应的下载链接去下载图片,进而得到图片的输入流,剩下的就交给图片的显示/加载类处理啦。那么我们可以设计出下面的接口:public i

2015-08-17 12:15:01 1070

原创 LeetCode题解:Contains Duplicate II

Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.题意:给定数组和整数k

2015-08-12 11:11:17 596

原创 LeetCode题解:Contains Duplicate

Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is

2015-08-12 11:08:29 493

原创 LeetCode题解:Rectangle Area

Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume that the total area is nev

2015-08-12 11:06:02 644

原创 LeetCode题解:Implement Stack using Queues

Implement the following operations of a stack using queues.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack.top() – Get the top element.empty() – Return whether t

2015-08-12 11:02:13 462

原创 LeetCode题解:Invert Binary Tree

Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 题意:将二叉树的左右子树互换解决思路:利用队列先进先出的特性改变左右子树代码:public TreeNode invertTree(

2015-08-12 10:55:58 462

原创 LeetCode题解:Summary Ranges

Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return [“0->2”,”4->5”,”7”].题意:给定一个有序数组,数组内没有重复元素,返回一个代表数组内数据范围的数组。解决思路:从左往右遍历,当后一个元素与

2015-08-12 10:50:50 583

原创 LeetCode题解:Power of Two

Given an integer, write a function to determine if it is a power of two.题意:给定一个整数,判断是否为2的幂解决思路:如果一个整数n是2的幂,那么让n和n-1进行与运算必然为0(位运算)代码:public boolean isPowerOfTwo(int n) { return ((n & (n-1))==0 &

2015-08-12 10:47:17 407

原创 LeetCode题解:Implement Queue using Stacks

Implement the following operations of a queue using stacks.push(x) – Push element x to the back of queue.pop() – Removes the element from in front of queue.peek() – Get the front element.empty() –

2015-08-12 10:42:37 478

原创 LeetCode题解:Palindrome Linked List

Given a singly linked list, determine if it is a palindrome.Follow up: Could you do it in O(n) time and O(1) space?题意:给定一个单向链表,判断是否为回文解决思路:假设一个链表是回文,那么把链表分割为1…n/2,n/2+1…n两个部分,这两个部分肯定是相同的(把第二部分顺序逆转过来或者

2015-08-12 10:39:25 463

原创 LeetCode题解:Lowest Common Ancestor of a Binary Search Tree

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two

2015-08-12 10:33:29 437

原创 LeetCode题解:Delete Node in a Linked List

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, t

2015-08-12 10:16:56 520

图片异步加载

博客 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关注的人

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