自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(30)
  • 收藏
  • 关注

原创 Leetcode172. Factorial Trailing Zeroes

题目 Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity. 思路 给出一个整数n,计算n的阶乘的结果,有多少个0 如果计算阶乘,然后再计算结果中有多少个0时,容易造成数据过大溢出;可以换个角度考虑,

2016-11-30 16:58:55 170

转载 JAVA多线程实现和应用总结

最近在做代码优化时学习和研究了下JAVA多线程的使用,看了菜鸟们的见解后做了下总结。 JAVA多线程实现方式 JAVA多线程实现方式主要有三种:继承Thread类、实现Runnable接口、使用ExecutorService、Callable、Future实现有返回结果的多线程。其中前两种方式线程执行完后都没有返回值,只有最后一种是带返回值的。 1、继承Thread类实现多线程 继承Thre

2016-11-30 14:48:22 134

原创 Leetcode219. 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. 给出一个整

2016-11-30 11:31:39 309

原创 Leetcode219. 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. 思路 从

2016-11-30 10:19:02 163

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

2016-11-29 21:19:54 159

原创 Leetcode27. Remove Element

一、原题Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant m

2016-11-29 14:18:00 134

原创 Leetcode26. Remove Duplicates from Sorted Array

一、原题Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in

2016-11-29 13:52:14 136

原创 Leetcode1. Two Sum

一、原题Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example:Gi

2016-11-28 22:06:33 152

原创 Leetcode414. 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:Inp

2016-11-28 21:25:03 210

原创 【学习笔记】JAVA中数组

一、数组的定义以及初始化三种方式:int [] nums=new int [nums.size];in [] nums=int []{1,4,5};int [] nums={1,2,3,4};

2016-11-28 20:54:20 222

原创 Leetcode442. Find All Duplicates in an Array

一、原题Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it

2016-11-28 20:19:46 161

原创 Leetcode448. Find All Numbers Disappeared in an Array

一、原题Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this

2016-11-28 17:52:37 170

原创 Leetcode350. Intersection of Two Arrays II

一、原题Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].二、思路与之前求两数组的重叠部分不同,这次要求交集可以有重复的元素。首先将两个数组进行排序

2016-11-28 17:29:46 149

转载 java中数组与List相互转换的方法

1、将list转化为数组调用ArrayList的toArray方法。  toArray  public T[] toArray(T[] a)返回一个按照正确的顺序包含此列表中所有元素的数组;返回数组的运行时类型就是指定数组的运行时类型。如果列表能放入指定的数组,则返回放入此列表元素的数组。否则,将根据指定数组的运行时类型和此列表的大小分配一个新的数组。  如果

2016-11-27 22:15:13 213

原创 Leetcode217. 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 el

2016-11-27 22:00:17 136

原创 Leetcode409. 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" 

2016-11-27 16:42:29 211

原创 Leetcode242. Valid Anagram

一、题目Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:Y

2016-11-27 15:56:33 169

原创 Leetcode387. First Unique Character in a String

一、题目Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.

2016-11-27 11:54:20 152

原创 Leetcode383. Ransom Note

一、题目Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the maga

2016-11-26 22:25:47 218

原创 Leetcode453. 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:[

2016-11-26 21:27:56 185

原创 Leetcode455. Assign Cookies

一、原题Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum siz

2016-11-26 20:26:15 265

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

2016-11-26 19:25:53 180

转载 java字符串与整数之间的互相转换

1、如何将字符串String转化为整数int  int i = Integer.parseInt(str);   int i = Integer.valueOf(my_str).intValue();    注: 字串转成Double, Float, Long的方法大同小异。 2、如何将字符串String转化为Integer   Integer integer=Integer.

2016-11-26 19:16:23 445

原创 Leetcode412. Fizz Buzz

一、题目Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five outpu

2016-11-26 19:08:11 192

原创 Leetcode171. Excel Sheet Column Number

一、原题Given a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28

2016-11-26 16:01:31 167

原创 Leetcode349. Intersection of Two Arrays

一、原题Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]Note:Each element in the result must be unique.The re

2016-11-26 15:47:18 206

原创 Leetcode283. 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 y

2016-11-26 15:32:21 197

原创 Leetcode389. Find the Difference

一、题目Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter

2016-11-26 14:52:16 201

原创 Leetcode14. Longest Common Prefix

一、原题Write a function to find the longest common prefix string amongst an array of strings.编写一个函数来查找字符串数组中最长的公共前缀字符串。二、解题思路1、先得到字串串数组中最短的字符串长度(公共前缀字符串的长度一定是小于最短字符串长度)2、从字符串数组的第一个元素的第一个字符开

2016-11-26 14:33:26 231

原创 Leetcode136. Single Number

一、原题Given an array of integers, every element appears twice except for one. Find that single one.给出一个整数数组,数组中只有一个元素出现一次,找出这个仅出现一次的数字Note:Your algorithm should have a linear runtime compl

2016-11-26 12:40:06 142

空空如也

空空如也

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

TA关注的人

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