自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(54)
  • 资源 (1)
  • 收藏
  • 关注

原创 LeetCode 009 Palindrome Number

题目描述Determine whether an integer is a palindrome. Do this without extra space.代码 public static boolean isPalindrome(int x) { if (x < 0) { return false; } if (x >= 0

2015-10-29 10:19:54 538

原创 LeetCode 008 String to Integer (atoi)

题目描述Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cas

2015-10-29 10:05:38 438

原创 LeetCode 007 Reverse Integer

题目描述Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321分析100,reverse后为1,不要前面的0reverse后可能溢出-Integer.MIN_VALUE == Integer.MIN_VALUE。 -Integer.MIN_VALUE = ~Inte

2015-10-29 09:38:12 435

原创 LeetCode 005 Longest Palindromic Substring

题目描述Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.代码 public static Str

2015-10-28 16:51:54 374

原创 LeetCode 003 Longest Substring Without Repeating Characters

题目描述Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for “abcabcbb” is “abc”, which the length is 3. F

2015-10-28 16:16:05 419

原创 LeetCode 002 Add Two Numbers

题目描述You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a l

2015-10-28 16:05:23 419

原创 LeetCode 001 Two Sum

题目描述Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, wher

2015-10-28 15:30:31 1207

原创 LeetCode 098 Validate Binary Search Tree

题目描述Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node’s key. The r

2015-10-27 23:15:48 450

原创 LeetCode 096 Unique Binary Search Trees

题目描述Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 unique BST’s.分析以n为根结点的二叉树个数=左子树个数*右子树个数用数组record[n+1]记录以0

2015-10-27 23:09:11 502

原创 LeetCode 095 Unique Binary Search Trees II

题目描述Given n, generate all structurally unique BST’s (binary search trees) that store values 1…n.For example, Given n = 3, your program should return all 5 unique BST’s shown below.代码 public class T

2015-10-27 22:59:52 373

原创 LeetCode 094 Binary Tree Inorder Traversal

题目描述Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3},return [1,3,2].Note: Recursive solution is trivial, could you do it iteratively?conf

2015-10-27 22:53:32 388

原创 LeetCode 093 Restore IP Addresses

题目描述Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example: Given “25525511135”,return [“255.255.11.135”, “255.255.111.35”]. (Order does

2015-10-26 12:46:22 461

原创 LeetCode 092 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 the followin

2015-10-26 09:42:38 410

原创 LeetCode 091 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 the total number

2015-10-26 09:12:57 372

原创 LeetCode 090 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 not contain dupli

2015-10-25 10:46:15 702

原创 LeetCode 089 Gray Code

题目描述The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of g

2015-10-25 10:19:44 415

原创 LeetCode 088 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) to hold additi

2015-10-25 10:00:39 521

原创 LeetCode 083 Remove Duplicates from Sorted List

题目描述Given a sorted linked list, delete all duplicates such that each element appear only once.For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3.代码/** * Definition for sing

2015-10-25 09:39:57 422

原创 LeetCode 082 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. Given 1->1->

2015-10-25 09:18:13 438

原创 LeetCode 081 Search in Rotated Sorted Array II

题目描述Follow up for “Search in Rotated Sorted Array”: What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the arra

2015-10-24 08:38:19 613

原创 LeetCode 080 Remove Duplicates from Sorted Array II

题目描述Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice?For example, Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first five el

2015-10-24 08:25:35 533

原创 LeetCode 079 Word Search

代码Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically ne

2015-10-24 08:06:16 541

原创 LeetCode 078 Subsets

题目描述Given a set of distinct integers, nums, return all possible subsets.Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. For example,

2015-10-23 17:18:21 669

原创 面试题 一个人射箭,每次分数在0至10之间,已知射箭10次,得分是50分,编程计算总共有多少种可能?

题目描述一个人射箭,每次分数在0至10之间,已知射箭10次,得分是50分,编程计算总共有多少种可能?例如: 10 10 10 10 10 0 0 0 0 0 0 0 0 0 0 10 10 10 10 10 是两种情况代码import java.util.ArrayList;import java.util.Arrays;import java.util.List;public clas

2015-10-23 11:26:00 1738 1

原创 LeetCode 077 Combinations

题目描述Given two integers n and k, return all possible combinations of k numbers out of 1 … n.For example, If n = 4 and k = 2, a solution is: [2,4], [3,4], [2,3], [1,2], [1,3], [1,4

2015-10-23 10:47:42 507

原创 LeetCode 075 Sort Colors

题目描述Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0

2015-10-23 09:52:37 635

原创 Java 八大排序之——归并排序

代码 private static void MergeSort(int[] a) { System.out.println("开始排序"); Sort(a, 0, a.length - 1); } private static void Sort(int[] a, int left, int right) { // !!!等于的时候

2015-10-18 09:36:14 438

原创 Java 八大排序之——快速排序

代码 public static int partition(int a[], int low, int high) { int privotKey = a[low]; while (low < high) { while (low < high && a[high] >= privotKey) { hig

2015-10-18 09:35:15 422

原创 Java 八大排序之——堆排序

代码 /* * 选择排序-堆排序 * * 若以一维数组存储一个堆,则堆对应一个完全二叉树,且所有非叶结点的值,不大于其子女的值 * 堆顶元素是最小的(小顶堆) * * * 已知H[s...m]除了H[s]外均满足堆的定义 调整H[s],使之成为大顶堆,将第s个结点为根的子树筛选 * * H:待调整的堆

2015-10-18 09:34:09 426

原创 LeetCode 074 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 ro

2015-10-17 20:24:43 592

原创 LeetCode 073 Set Matrix Zeroes

题目描述Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up: Did you use extra space? A straight forward solution using O(mn) sp

2015-10-17 19:38:23 645

原创 Java 八大排序之——简单选择排序

分析选出最小的元素,与数组第一个位置交换选出第i小的元素,与数组第i个位置交换直到第n-1个元素,与第n个元素比较为止代码 /* * 选择排序-简单选择排序 * 基本思想:在一组要排序的数中,选取最小的与第一个位置交换 */ public static int SelectMinKey(int a[], int i) { int k

2015-10-17 16:49:32 360

原创 Java 八大排序之——希尔排序

分析又叫缩小增量排序。将待排序列,分割成若干子序列进行直接插入排序序列基本有序时,对全体进行直接插入排序 方法选择增量序列,t1,t2,…,tkt_1,t_2,…,t_k ,序列依次递减,tk=1t_k=1按增量序列个数k,进行k次排序根据增量tit_i,对子序列进行直接插入排序。当增量为1时,整个序列作为一个表处理,得到排序后的数组代码 public static v

2015-10-17 16:42:21 407

原创 Java 八大排序之——直接插入排序

分析将一个记录插入到已排序好的有序表中,从而得到一个新,记录数增1的有序表。即:先将序列的第1个记录看成是一个有序的子序列,然后从第2个记录逐个进行插入,直至整个序列有序为止。要点:设立哨兵,作为临时存储和判断数组边界之用。 如果碰见一个和插入元素相等的,那么插入元素把想插入的元素放在相等元素的后面。所以,相等元素的前后顺序没有改变,从原无序序列出去的顺序就是排好序后的顺序,所以插入排序是稳定

2015-10-17 14:01:48 437

原创 Java 八大排序之——冒泡排序

分析每相邻两个数比较,大的向右沉,数据“冒泡”。每一次排序,能使最大的排在最后。代码 /* * 算法改进:加一个标志位,记录每趟排序最后一个进行交换的位置,下一次只需扫描到pos */ public static void bubbleSort(int a[]) { int i = a.length - 1; while (i > 0

2015-10-17 13:56:42 410

原创 Java的垃圾回收机制

引用计数简单但速度很慢。 原理:每个对象都含有一个引用计数器。有引用连接到对象,引用计数+1;引用离开作用域或置为null时,引用计数-1。缺点:在整个程序生命周期中,持续发生;如果对象中存在循环引用,会出现“对象应该被回收,但引用计数不为0”的情况;定位循环引用的工作量很大,Java虚拟机没有采用。Tracing算法对任何“活”的对象,一定能追溯到其存活在堆栈或静态存储区的引用

2015-10-17 11:38:51 566

原创 Android Handler源码分析

为什么Android只能在UI线程更新UI?解决多线程并发问题提高界面更新的性能架构设计简单Handler消息模型 Looper类 主要成员变量和方法: private static final String TAG = "Looper"; // sThreadLocal.get() will return null unless you've called prep

2015-10-17 09:59:00 863 5

原创 HTTP

HTTP操作过程建立TCP连接HTTP请求报文,请求文档HTTP响应报文,响应文档释放TCP连接HTTP版本HTTP/1.0 缺点:非持续连接。每请求一个稳定,就要有两倍的RTT开销。 HTTP/1.1 优点:持续连接。服务器在发送响应后,在一段时间内保持这条连接。同一浏览器和该服务器可以继续在该连接上,传送后续的HTTP请求报文和响应报文。HTTP报文结构请求报文的方法 方法(操作

2015-10-16 21:26:18 684 1

原创 Android调试 Logcat中查看System.out信息

描述在Android开发中,要打印变量的值,可以使用: 1. Log.i输出,但是有太多底层信息 2. TextView显示,但是太麻烦查看System.out在Logcat窗口下单击绿色“+”

2015-10-10 16:10:53 695

原创 HTTPS概述

什么是HTTPSHTTP:浏览网页时的协议,数据未加密,明文传输。HTTPS:为了对HTTP的数据加密传输,网景公司设计了SSL(Secure Sockets Layer)协议。工作原理浏览器将自己支持的加密规则发送给网站。网站选出一组加密算法、HASH算法,并将自己的身份信息以证书的形式发送给浏览器。证书里包括:网站地址、加密公钥、证书颁发机构。浏览器获取证书后: 验证证书合法性浏

2015-10-10 15:59:18 571

Java 虚拟机面试题全面解析(干货)

Java 虚拟机面试题全面解析,《深入理解Java虚拟机》干货版,自己总结,希望能够帮助大家,免费下载~

2016-03-22

空空如也

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

TA关注的人

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