自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 LeetCode 359 Logger Rate Limiter

Problem:Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it isnot printed in the last 10 seconds.Given a messag...

2017-01-04 12:42:00 146

转载 LeetCode 204 Count Primes

Problem:Count the number of prime numbers less than a non-negative number,n.Summary:判断小于某非负数n的质数个数。Solution:用所谓的“刷质数表”的方式先用HashTable记录小于n的所有数是质数还是合数,再逐一数出。看了题目中的Hint才知道这种方法有一个更加高大上的名...

2017-01-04 10:00:00 168

转载 LeetCode 205 Isomorphic Strings

Problem:Given two stringssandt, determine if they are isomorphic.Two strings are isomorphic if the characters inscan be replaced to gett.All occurrences of a character must be replace...

2017-01-04 08:54:00 154

转载 LeetCode 299 Bulls and Cows

Problem:You are playing the followingBulls and Cowsgame 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 pro...

2017-01-03 13:03:00 140

转载 LeetCode 290 Word Pattern

Problem:Given apatternand a stringstr, find ifstrfollows the same pattern.Herefollowmeans a full match, such that there is a bijection between a letter inpatternand anon-emptyword ...

2017-01-03 08:11:00 92

转载 LeetCode 36 Valid Sudoku

Problem:Determine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character'.'.A partiall...

2017-01-03 07:07:00 94

转载 LeetCode 209 Minimum Size Subarray Sum

Problem:Given an array ofnpositive integers and a positive integers, find the minimal length of a subarray of which the sum ≥s. If there isn't one, return 0 instead.For example, given the...

2017-01-02 13:29:00 85

转载 LeetCode 162 Find Peak Element

Problem:A peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple...

2017-01-02 11:24:00 180

转载 LeetCode 167 Two Sum II - Input array is sorted

Problem:Given an array of integers that is alreadysorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of t...

2017-01-01 13:18:00 101

转载 LeetCode 64 Minimum Path Sum

Problem:Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:You can only move either dow...

2017-01-01 11:17:00 68

转载 LeetCode 66 Plus One

Problem: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.Summary:...

2017-01-01 08:29:00 91

转载 LeetCode 88 Merge Sorted Array

Problem:Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough space (size that is greater or equal tom+n) to...

2016-12-31 13:42:00 85

转载 LeetCode 27 Remove Element

Problem: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 constan...

2016-12-30 11:35:00 65

转载 LeetCode 26 Remove Duplicates from Sorted Array

Problem:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for another array, you must do this ...

2016-12-30 11:11:00 68

转载 LeetCode 448 Find All Numbers Disappeared in an Array

Problem: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 th...

2016-12-30 09:20:00 142

转载 LeetCode 219 Contains Duplicate II

Problem:Given an array of integers and an integerk, find out whether there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the difference betweeniandjis at mo...

2016-12-29 11:26:00 107

转载 LeetCode 118 Pascal's Triangle

Problem:GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]Summary:输...

2016-12-29 01:24:00 78

转载 LeetCode 119 Pascal's Triangle II

Problem:Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(k) extra space?Summary...

2016-12-28 12:19:00 73

转载 LeetCode 1 Two Sum

Problem:Given an array of integers, returnindicesof the two numbers such that they add up to a specific target.You may assume that each input would haveexactlyone solution.Example:Giv...

2016-12-28 09:18:00 81

转载 LeetCode 414 Third Maximum Number

Problem:Given anon-emptyarray of integers, return thethirdmaximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1:In...

2016-12-28 09:08:00 68

转载 LeetCode 459 Repeated Substring Pattern

Problem:Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of ...

2016-12-28 05:28:00 90

转载 LeetCode 455 Assign Cookies

Problem: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 minimu...

2016-12-18 12:07:00 81

转载 LeetCode 463 Island Perimeter

Problem:You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid...

2016-12-16 12:58:00 99

转载 LeetCode 409 Longest Palindrome

Problem: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"A...

2016-12-16 05:57:00 94

转载 LeetCode 404 Sum of Left Leaves

Problem:Find the sum of all left leaves in a given binary tree.Summary:求左子叶之和。Analysis:1. 求左子叶之和,即需要遍历整棵二叉树,常规的方法则为递归。首先我想到的是调用子函数,在子函数中递归,每递归至一个新的节点,首先传入bool类型标记是根节点的左子树还是右子树。若为左子树,且为叶...

2016-12-16 05:42:00 53

转载 LeetCode 447 Number of Boomerangs

Problem:Givennpoints in the plane that are all pairwise distinct, a "boomerang" is a tuple of points(i, j, k)such that the distance betweeniandjequals the distance betweeniandk(the o...

2016-11-15 12:44:00 64

转载 LeetCode 453 Minimum Moves to Equal Array Elements

Problem:Given anon-emptyinteger array of sizen, find the minimum number of moves required to make all array elements equal, where a move is incrementingn- 1 elements by 1.Example:Input...

2016-11-12 13:40:00 85

转载 LeetCode 112 Path Sum

Problem:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary ...

2016-11-08 00:25:00 54

转载 LeetCode 437 Path Sum III

Problem: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 l...

2016-11-07 23:35:00 54

转载 LeetCode 263 Ugly Number

Problem:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For example,6, 8are ugly while14is no...

2016-11-05 11:57:00 168

转载 LeetCode 191 Number of 1 Bits

Problem:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit integer ’11' has binary representa...

2016-11-05 08:59:00 82

转载 LeetCode 70 Climbing Stairs

Problem:You are climbing a stair case. It takesnsteps 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?Summary:n级楼梯,每次...

2016-11-05 07:49:00 72

转载 LeetCode 83 Remove Duplicates from Sorted List

Problem:Given a sorted linked list, delete all duplicates such that each element appears onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, return1-&g...

2016-11-04 23:56:00 73

转载 LeetCode 202 Happy Number

Problem: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 o...

2016-11-03 09:06:00 83

转载 LeetCode 326 Power of Three

Problem:Given an integer, write a function to determine if it is a power of three.Could you do it without using any loop / recursion?Summary:用非循环/递归的方法判断数n是否为3的整数幂。Analysis:1. 循环:将n逐次...

2016-11-02 09:34:00 83

转载 LeetCode 231 Power of Two

Problem:Given an integer, write a function to determine if it is a power of two.Summary:判断一个数n是不是2的整数幂。Analysis:这道题首先需要注意n为非整数是返回false的情况。1. 若将n转换为二进制数,如果n为2的整数幂,则转换得到的二进制数只包含一个一,故计算转...

2016-11-01 12:04:00 101

转载 LeetCode 441 Arranging Coins

Problem:You have a total ofncoins that you want to form in a staircase shape, where everyk-th row must have exactlykcoins.Givenn, find the total number offullstaircase rows that can b...

2016-11-01 11:35:00 63

转载 LeetCode 415 Add Strings

Problem:Given two non-negative numbersnum1andnum2represented as string, return the sum ofnum1andnum2.The length of bothnum1andnum2is < 5100.Bothnum1andnum2contains only ...

2016-10-31 08:31:00 67

转载 LeetCode 206 Reverse Linked List

Problem:Reverse a singly linked list.A linked list can be reversed either iteratively or recursively. Could you implement both?Summary:翻转链表。Analysis:1. Iterative solution 1 /** ...

2016-10-30 23:07:00 84

转载 LeetCode 13 Roman to Integer

Problem:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.Summary:将罗马数字转换为十进制阿拉伯数字。Analysis:罗马数字和阿拉伯数字的转换关系如下图:罗马数字的基本字符:...

2016-10-30 12:14:00 113

空空如也

空空如也

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

TA关注的人

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