自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

学渣记事本

打渔还是晒网?

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

原创 配置备忘

manven  setting.xml<!--Licensed to the Apache Software Foundation (ASF) under oneor more contributor license agreements. See the NOTICE filedistributed with this work for additional inform

2017-03-27 21:22:50 427

原创 靠近左、右的二分搜索例程

靠近左:只有当arr[mid]>1),最后位置在lo靠近右:只有当arr[mid]>target时才向左,上界hi推进,mid=lo+((hi-lo+1)>>1),最后位置在hipublic class test649 { public static void main(String[] args) { int[] arr={1,1,1,1,2,2,3,4,5,6,6

2017-03-22 16:27:17 348

原创 面试题(微软)S-expression

S-expression is a prefix notation invented for and popularized by the programming language Lisp. Your task is to evaluate some simple S-expressions.In this problem, S-expression is defined as:1.

2017-01-02 17:37:48 1885

原创 链式前向星

摘自http://www.cnblogs.com/LQ-double/p/5971323.htmlhttps://www.baidu.com/link?url=mJSzzTO-saQexGiBxZDXQzBLZArVveITjVSqBnLXU-_wixEOCZagAoy6VbvYqQs0&wd=&eqid=e579ac6d00002777000000065829af79

2016-11-14 20:38:52 320

原创 全排列散列

//x为排列的排名,范围[0~n!-1] //n为字符的个数 public static String intToArray(int x,int n) { boolean[] used=new boolean[n+1]; StringBuilder sb=new StringBuilder(); for(int i=1;i<=n;i++) { int temp=x/fa

2016-11-14 15:32:32 316

原创 素数晒法、素数Rabin测试、快速幂取模

素数筛法,产生num以内的素数表public static int makePrimes(int primes[], int num) { int i, j, cnt; primes[0] = 2; primes[1] = 3; for(i = 5, cnt = 2; i < num; i += 2) { boolean flag = true; for(j

2016-11-14 10:43:47 677

原创 欧拉函数

摘自http://blog.csdn.net/once_hnu/article/details/6302868欧拉函数      对正整数n,欧拉函数是少于或等于n的数中与n互质的数的数目。例如euler(8)=4,因为1,3,5,7均和8互质。     Euler函数表达通式:euler(x)=x(1-1/p1)(1-1/p2)(1-1/p3)(1

2016-11-14 10:28:25 229

转载 453. Minimum Moves to Equal Array Elements

Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.Example:Input:[1,2,3]Ou

2016-11-13 16:41:12 345

原创 452. Minimum Number of Arrows to Burst Balloons

There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordin

2016-11-13 15:30:26 207

原创 447. Number of Boomerangs

Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the distance between iand j equals the distance between i and k (the order of t

2016-11-13 11:30:41 229

原创 446. Arithmetic Slices II - Subsequence

A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequen

2016-11-13 09:51:10 428

原创 441. Arranging Coins

You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.Given n, find the total number of full staircase rows that can be formed.

2016-11-09 22:12:01 204

转载 440. K-th Smallest in Lexicographical Order

Given integers n and k, find the lexicographically k-th smallest integer in the range from 1 to n.Note: 1 ≤ k ≤ n ≤ 109.Example:Input:n: 13 k: 2Output:10Explanation:The lexicograp

2016-11-09 22:08:29 644

原创 438. Find All Anagrams in a String

Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.Strings consists of lowercase English letters only and the length of both strings s and p will not be lar

2016-11-09 22:04:24 252

原创 437. Path Sum III

You are given a binary tree in which each node contains an integer value.Find the number of paths that sum to a given value.The path does not need to start or end at the root or a leaf, but it

2016-11-09 21:51:19 171

原创 436. Find Right Interval

Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point of the interval i, which can be called that j is on

2016-11-09 21:45:33 219

原创 435. Non-overlapping Intervals

Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.Note:You may assume the interval's end point is alw

2016-11-09 21:35:14 237

原创 432. All O`one Data Structure

Implement a data structure supporting the following operations:Inc(Key) - Inserts a new key with value 1. Or increments an existing key by 1. Key is guaranteed to be a non-empty string.Dec(Key

2016-11-09 21:15:43 644

原创 424. Longest Repeating Character Replacement

Given a string that consists of only uppercase English letters, you can replace any letter in the string with another letter at most k times. Find the length of a longest substring containing all repe

2016-11-09 21:12:13 429

原创 423. Reconstruct Original Digits from English

Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order.Note:Input contains only lowercase English letters.Input is g

2016-11-09 20:36:47 264

转载 421. Maximum XOR of Two Numbers in an Array

Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231.Find the maximum result of ai XOR aj, where 0 ≤ i, j n.Could you do this in O(n) runtime?Example:Input:

2016-11-09 20:31:46 196

转载 420. Strong Password Checker

A password is considered strong if below conditions are all met:It has at least 6 characters and at most 20 characters.It must contain at least one lowercase letter, at least one uppercase letter,

2016-11-09 20:27:22 670

原创 419. Battleships in a Board

Given an 2D board, count how many different battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may assume the following rules:You receiv

2016-11-09 20:22:29 259

原创 417. Pacific Atlantic Water Flow

Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" tou

2016-11-09 20:11:37 188

原创 416. Partition Equal Subset Sum

Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.Note:Each of the array

2016-11-09 19:59:08 160

原创 415. Add Strings

Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 contains only digits 0-9.B

2016-11-09 19:53:14 151

原创 414. Third Maximum Number

Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1:Input: [3, 2,

2016-11-09 19:49:32 217

原创 413. Arithmetic Slices

A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequenc

2016-11-09 19:33:44 176

原创 410. Split Array Largest Sum

Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m sub

2016-11-09 19:21:03 398

原创 409. Longest Palindrome

Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example "Aa" is not con

2016-11-09 16:58:51 157

转载 407. Trapping Rain Water II

Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining.Note:Both m and n are l

2016-11-09 16:55:43 451

转载 406. Queue Reconstruction by Height

Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of t

2016-11-09 16:49:29 226

原创 405. Convert a Number to Hexadecimal

Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used.Note:All letters in hexadecimal (a-f) must be in lowercase.The hexade

2016-11-09 16:46:14 145

转载 400. Nth Digit

Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...Note:n is positive and will fit within the range of a 32-bit signed integer (n 31).Example 1:Input

2016-11-09 16:40:31 161

原创 399. Evaluate Division

Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answ

2016-11-09 16:18:26 279

原创 398. Random Pick Index

Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.Note:The array size c

2016-11-09 16:00:19 178

原创 397. Integer Replacement

Given a positive integer n and you can do operations as follow:If n is even, replace n with n/2.If n is odd, you can replace n with either n + 1 or n - 1.What is the minimum number o

2016-11-09 15:44:13 191

原创 396. Rotate Function

Given an array of integers A and let n to be its length.Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a "rotation function" F on A as follow:

2016-11-09 15:41:05 128

转载 395. Longest Substring with At Least K Repeating Characters

Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times.Example 1:Input:s = "aaabb", k =

2016-11-09 15:18:49 157

原创 394. Decode String

Given an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note thatk is

2016-11-09 11:48:13 144

空空如也

空空如也

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

TA关注的人

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