自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 [Leetcode] 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-10-06 15:44:49 252

原创 [Leetcode] 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 place with

2016-09-29 14:05:03 205

原创 [Leetcode] 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 memory.

2016-09-29 13:18:31 268

原创 [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.本题方法是从最后一位开始加进制位,个数加

2016-09-29 12:05:17 228

转载 给 Android 初学者的 Gradle 知识普及

本文原创作者微信公众号 AndroidDeveloper「googdev」,csdn博客网站http://blog.csdn.net/googdev,强烈推荐1. 前言前一段时间有人在我的邪教群里问「刚学 Android 不久,对 Gradle 不懂,看了很多资料依然一知半解,希望张哥给讲讲 Gradle 」,没想到群里很多人都响应,表示同感,有人在群里推荐了一本书,说

2016-09-28 17:00:34 402

原创 [Leetcode] 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 f

2016-09-28 13:09:04 195

原创 [Leetcode] 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 complexity. Could you implement it without using ext

2016-09-28 12:40:59 185

原创 [Leetcode] 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 
constru

2016-09-28 12:32:33 210

原创 [Leetcode] 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.Note: 

2016-09-28 12:10:40 215

原创 [Leetcode] 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-09-28 10:48:28 252

原创 [Leetcode] 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 that was

2016-09-20 23:10:17 191

原创 [Leetcode] Is Subsequence

Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) strin

2016-09-20 22:23:52 294

原创 [Leetcode] 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-09-20 18:12:38 191

原创 [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.方法1:利用系统方法String.indexOf(),耗时6mspublic class Solution { publ

2016-09-19 16:12:29 188

原创 [Leetcode] 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:Given nums =

2016-09-19 14:20:20 190

原创 [Leetcode] 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-09-19 13:55:38 480

原创 [Leetcode] 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-09-18 23:18:22 223

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

2016-09-18 22:22:41 186

原创 [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[] strs) { Arrays.sort(strs);

2016-09-18 22:03:22 195

转载 [转载]Longest Common Prefix 算法

Question:Write a function to find the longest common prefix string amongst an array of strings.Quick NavigationSolutionApproach #1 (Horizontal scanning)Approach #2 (Vertical

2016-09-18 21:57:36 495

原创 [Leetcode] Length of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is

2016-09-18 20:51:57 148

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

2016-09-18 20:22:17 169

原创 [Leetcode] 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 add

2016-09-18 12:12:06 174

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

2016-09-17 19:22:25 128

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

2016-09-17 15:10:01 154

原创 [Leetcode] Bulls and Cows

You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint t

2016-09-16 17:49:17 161

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

2016-09-16 17:48:06 317

原创 [Leetcode] Power of Four

Given an integer (signed 32 bits), write a function to check whether it is a power of 4.Example:Given num = 16, return true. Given num = 5, return false.Follow up: Could you solve it without

2016-09-16 17:46:55 214

原创 [Leetcode] Reverse Vowels of a String

Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle".Example 2:Given s = "leetcode", return "leotcede".Note

2016-09-16 17:45:13 162

原创 [Leetcode] Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),

2016-09-16 17:38:05 218

原创 [Leetcode] Climbing Stairs

ou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?public class Solution { p

2016-09-16 17:36:10 142

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

2016-09-16 17:35:13 135

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

2016-09-16 17:30:45 153

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

2016-09-16 17:29:24 140

原创 [Leetcode] Power of Two

Given an integer, write a function to determine if it is a power of two.Credits:Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases.public class So

2016-09-16 17:28:23 135

原创 [Leetcode] Power of Three

Given an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?public class Solution { public boolean isPowerO

2016-09-16 17:27:00 165

原创 [Leetcode] 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].Note:Each element in the result should appear as ma

2016-09-16 17:25:44 159

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

2016-09-16 17:24:46 162

原创 [Leetcode] Majority Element

Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element

2016-09-16 17:23:31 162

原创 [Leetcode] 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:You may a

2016-09-15 22:45:14 175

空空如也

空空如也

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

TA关注的人

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