自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(58)
  • 资源 (2)
  • 收藏
  • 关注

原创 数组组合问题

输入一个字符串,输出该字符串中字符的所有组合。举个例子,如果输入abc,它的组合有a、b、c、ab、ac、bc、abc。假设我们想在长度为n的字符串中求m个字符的组合。我们先从头扫描字符串的第一个字符。针对第一个字符,我们有两种选择:一是把这个字符放到组合中去,接下来我们需要在剩下的n-1个字符中选取m-1个字符;二是不把这个字符放到组合中去,接下来我们需要在剩下的n-1个字符中选择m个字

2017-04-07 21:32:24 385 1

原创 offer45

import java.util.ArrayList;/** * Created by WHZ on 2017/4/7. */public class offer45 { static int LastRemaining(int n,int m){ if(n<1||m<1) return -1; int i=0;

2017-04-07 17:07:47 218

原创 offer44

import java.util.Arrays;/** * Created by WHZ on 2017/4/7. */public class offer44 { boolean IsContinuous(int[] numbers,int length){ if(numbers==null||length<1) return fal

2017-04-07 16:58:17 203

原创 剑指offer43:n个骰子的点数

import java.util.Properties;/** * Created by WHZ on 2017/4/7. */public class offer42 { static int maxValue = 6; static void PrintProbability(int number){ if(number<1)

2017-04-07 16:03:48 260

原创 剑指offer41:和为s的两个数字VS和为s的连续正数序列

/** * Created by WHZ on 2017/4/7. */public class offer41 { boolean FindNumbersWithSum(int[] data,int length,int sum,int[] num1,int[] num2){ boolean found = false; if(length<1||

2017-04-07 14:51:53 203

原创 剑指offer40:数组中只出现一次的数字

/** * Created by WHZ on 2017/4/7. */public class offer40 { static void FindNumsAppearOnce(int[] data, int[] num1, int[] num2){ if(data==null||data.length<2) return;

2017-04-07 14:32:21 174

原创 剑指offer39:二叉树的深度

/** * Created by WHZ on 2017/4/7. */public class offer39 { private class TreeNode{ TreeNode left; TreeNode right; int val; } int TreeDepth(TreeNode root){

2017-04-07 14:18:07 194

原创 剑指offer38:数字在排序数组出现的次数

/** * Created by WHZ on 2017/4/7. */public class offer38 { int getUpper(int arr[], int key){//获取某个元素最后出现位置 int low = 0, high = arr.length - 1; //其实是一个递归迭代 while(low < h

2017-04-07 11:09:11 334

原创 offer37:两个链表的第一个公共节点

/** * Created by WHZ on 2017/4/7. */public class offer37 { private class ListNode{ ListNode next; int val; } ListNode FindFirstCommonNode(ListNode p1,ListNode p2){

2017-04-07 10:39:41 147

原创 剑指offer36:数组中的逆序对

/** * Created by WHZ on 2017/4/7. */public class offer36 { static int InverseParis(int[] data){ if(data==null||data.length<0) return 0; int length = data.length;

2017-04-07 10:30:50 194

原创 剑指offer35:第一个只出现一次的字符

/** * Created by WHZ on 2017/4/6. */public class offer35 { static char FirstNotRepeatingChar(String a){ if(a==null) return '\0'; int[] hashTable = new int[256];

2017-04-06 22:43:58 242

原创 剑指offer34:丑数

/** * Created by WHZ on 2017/4/6. */public class offer34 { static int GetUglyNumber_Solution(int index){ if(index <= 0) return 0; int[] uglyNumbers = new int[index]

2017-04-06 22:08:33 371

原创 剑指offer33:把数组排成最小的数

import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;/** * Created by WHZ on 2017/4/6. */public class offer33 { public static String PrintMinNumber(int [] nu

2017-04-06 21:30:49 232

原创 剑指offer32:从1到n整数1出现的次数

/** * Created by WHZ on 2017/4/6. */public class offer32 { static int NumberOf1Between1AndN(int n){ if(n<=0) return 0; String str = String.valueOf(n); char[

2017-04-06 17:20:38 232

原创 剑指offer31:连续子数组的最大和

/** * Created by WHZ on 2017/4/6. */public class offer31 { static int FindGreatestSumOfSubArray(int[] data){ if(data==null||data.length<=0){ return 0; } int

2017-04-06 16:38:49 172

原创 剑指offer30:最小的k个数

解法1:static int Partion(int[] r,int first,int end){ int i = first; int j = end; int pivot = r[i]; while(i<j){ while((i=pivot) j--;

2017-04-06 16:13:17 215

原创 剑指offer29:数组中出现次数超过一半的数字

/** * Created by WHZ on 2017/4/6. */public class offer29 { //超过一半的数字为排序数组的中位数 static int Partion(int[] r,int first,int end){ int i = first; int j = end; int pivot =

2017-04-06 15:26:55 242

原创 剑指offer28:字符串的排列

import java.util.ArrayList;/** * Created by WHZ on 2017/4/6. */public class offer28 { static ArrayList res = new ArrayList(); String cur = new String(); public ArrayList Permutation

2017-04-06 09:56:06 281

原创 剑指offer27:二叉搜索树与双向链表

/** * Created by WHZ on 2017/4/5. */public class offer27 { private class BinaryTreeNode{ int val; BinaryTreeNode left; BinaryTreeNode right; } BinaryTreeNode C

2017-04-05 22:35:23 171

原创 剑指offer26:复杂链表复制

/** * Created by WHZ on 2017/4/5. */public class offer26 { private class ComplexListNode{ int val; ComplexListNode next; ComplexListNode sibling; } void CloneN

2017-04-05 11:38:54 203

原创 剑指offer25:二叉树中和为某一值得路径

import java.util.LinkedList;import java.util.Stack;/** * Created by WHZ on 2017/4/1. */public class offer25 { private class TreeNode{ int val; TreeNode left; TreeNod

2017-04-01 15:51:26 189

原创 剑指offer24:二叉搜索树的后序遍历序列

/** * Created by WHZ on 2017/4/1. */public class offer24 { boolean VerifySequenceOfBST(int sequence[],int start,int end){ if(sequence==null||sequence.length<=0) return false; in

2017-04-01 15:28:14 191

原创 剑指offer23:从上到下打印二叉树

import java.util.LinkedList;import java.util.Queue;/** * Created by WHZ on 2017/4/1. */public class offer23 { private class TreeNode{ int val; TreeNode left; TreeNod

2017-04-01 11:35:20 168

原创 剑指offer22:栈的压入、弹出序列

import java.util.Stack;/** * Created by WHZ on 2017/4/1. */public class offer22 { boolean IsPopOrder(int[] pPush,int[] pPop,int length){ boolean bPossible = false; if(pPush!=

2017-04-01 11:20:10 164

原创 offer21:包含min函数的栈

import java.util.Stack;/** * Created by WHZ on 2017/4/1. */public class offer21 { Stack data = new Stack<>(); Stack min = new Stack<>(); void push(int val){ data.push(val);

2017-04-01 10:31:56 219

原创 剑指offer20:顺时针打印矩阵

/** * Created by WHZ on 2017/3/31. */public class offer20 { void PrintMatrixClockwisely(int[][] numbers){ if(numbers==null||numbers.length<=0) return; int start = 0; int

2017-03-31 17:16:22 180

原创 剑指offer19:二叉树的镜像

/** * Created by WHZ on 2017/3/31. */public class offer19 { private class TreeNode{ TreeNode left; TreeNode right; int val; } void MirrorRecursively(TreeNode pN

2017-03-31 16:10:35 234

原创 剑指offer18:树的子结构

/** * Created by WHZ on 2017/3/31. */public class offer18 { private class TreeNode{ TreeNode left; TreeNode right; int val; } boolean HasSubtree(TreeNode pRoot

2017-03-31 15:31:56 196

原创 剑指offer17:合并两个排序的链表

/** * Created by WHZ on 2017/3/31. */public class offer17 { private class ListNode{ int val; ListNode next; } ListNode Merge(ListNode pHead1,ListNode pHead2){

2017-03-31 15:20:02 445

原创 剑指offer15:链表中倒数第k个节点

/** * Created by WHZ on 2017/3/31. */public class offer15 { private class ListNode{ int val; ListNode next; } ListNode FindKthToTail(ListNode pHead,int k){ if(p

2017-03-31 15:00:16 287

原创 剑指offer14:将数组奇数移到偶数前面

/** * Created by WHZ on 2017/3/31. */public class offer14 { void ReorderOddEven(int[] data){ if(data==null||data.length==0) return; int begin = 0; int end = data.length

2017-03-31 11:41:08 388 1

原创 剑指offer13:O(1)时间删除链表节点

/** * Created by WHZ on 2017/3/31. */public class offer13 { private class ListNode{ int val; ListNode next; } void DeleteNode(ListNode pHead, ListNode pDelete){

2017-03-31 11:31:05 173

原创 剑指offer12:打印1到最大的n位数

void Print1ToMaxOfNDigits(int n){ if(n<=0) return; char[] number = new char[n]; for(int i=0;i<10;i++){ number[0] = (char)('0'+i); Print1ToMaxOfNDigitsRe

2017-03-31 11:13:25 160

原创 剑指offer11:数值的整数次方

double Power(double base,int exponent){ if(base==0&&exponent<0){ return 0.0; } int absExponent = exponent; if(exponent<0) absExponent = -exponen

2017-03-31 10:51:24 158

原创 剑指offer10:二进制1的个数

int NumberOf1(int n){ int count = 0; while(n!=0){ ++count; n = (n-1)&n; } return count; }

2017-03-31 10:27:42 169

原创 剑指offer9:Fibonacci数列

long Fibonacci(int n){ if(n<=0) return 0; if(n==1) return 1; return Fibonacci(n-2)+Fibonacci(n-1); } long Fibonacci2(int n){ if(n<=0) return 0; if(n==1

2017-03-31 10:19:24 170

原创 旋转数组查找指定的数

思路:在有序的范围内使用二分法查找。int search(int A[], int n, int target) { int beg = 0; int end = n - 1; while (beg <= end) { int mid = beg + (end - beg) / 2;

2017-03-31 10:09:57 694

原创 剑指offer8:旋转数组的最小数字

题目:把一个数组最开始的若干元素搬到数组的末尾,我们称之为数组的旋转。输入一个递增排序的数组的一个旋转,输出旋转数组的最小元素。public static int Min(int[] number){ if(number==null|| number.length==0){ return 0; } int index1 =

2017-03-31 09:59:19 187

原创 剑指offer7:用两个栈实现队列

static Stack stack1 = new Stack<>(); static Stack stack2 = new Stack<>(); public static void push(int x){ stack1.push(x); } public static Integer pop(){ int temp = 0;

2017-03-30 16:37:30 246

原创 剑指offer6:重建二叉树

static private class TreeNode{ int val; TreeNode left; TreeNode right; } static TreeNode Construct(int[] pre,int[] in){ if (pre == null || in == null || pre.le

2017-03-30 16:16:55 156

Android ListView 实例

Android ListView 实例 ListViewAdapter

2015-01-21

Android根据GPS位置获得天气的程序

Android根据GPS位置获得天气的程序

2014-12-28

空空如也

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

TA关注的人

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