- 博客(21)
- 收藏
- 关注
原创 LeetCode 231,326,342 --Power of Two & Three & Four
Given an integer, write a function to determine if it is a power of two & three & four.Two:这几个题,都可以用同一种解法,用当前数一直整除另一个数,一旦无法整除,且余数不为0;则说明不是 2& 3& 4的幂:public class Solution { public boolean isPo
2016-09-13 09:17:56
260
原创 Leetcode 191 -- Number of 1 bits
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 representation00000000
2016-09-12 18:38:21
252
原创 LeetCode 8 -- String to Integer (atoi)
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input case
2016-09-12 17:21:22
267
原创 Leetcode247 -- StroboGrammatic NumberII
247.StroboGrammatic NumberII题目:A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).Find all strobogrammatic numbers that are of length = n
2016-09-11 23:57:24
366
原创 LeetCpde 246 -- Strobogrammatic Numbe I
Strobogrammatic Number IA strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).Write a function to determine if a number is strobogrammatic. Th
2016-09-11 23:20:16
476
原创 LeetCode 15 -- 3 Sum
LeetCode 15 -- 3 SumGiven an array S of n integers, are there elements a,b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution
2016-09-11 16:27:45
288
原创 LeetCode 14 -- Longest Common Prefix
leetcode 14: Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.解答: 给定一组字符串,找出他们的最长公共子序列。public class Solution { public Strin
2016-09-11 16:15:57
221
原创 Leetcode 257 -- Binary Tree Paths
Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are: ["1->2->5", "1->3"] 解法:
2016-09-11 14:52:55
184
原创 LeetCode 121 -- Best Time to Buy and Sell Stock I
Say you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),
2016-09-11 13:41:13
254
原创 LeetCode 112&113 --Path Sum I & II;
Path Sum IGiven 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 tr
2016-09-11 13:37:04
215
原创 LeetCode 188 - Best Time to Buy and Sell Stock IV
Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at mostk transactions.Note:You may not
2016-09-09 16:57:34
217
原创 LeetCode 123 -- Best Time to Buy and Sell Stock III
LeetCode 123 -- Best Time to Buy and Sell Stock IIISay you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You ma
2016-09-09 14:58:52
229
原创 LeetCode 309.--Best Time to Buy and Sell Stock with Cooldown
309. Best Time to Buy and Sell Stock with CooldownSay you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may
2016-09-09 14:51:02
201
原创 LeetCode 122 -- Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one
2016-09-09 14:32:16
295
原创 LeetCode 38 -- Count and Say
LeetCode 38 -- Count and SayThe count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as
2016-09-07 23:38:46
234
原创 LeetCode -- 62 Unique Paths
LeetCode -- 62 Unique PathsA robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time.
2016-09-07 16:48:35
215
原创 LeetCode -- 63 Unique Paths II
LeetCode -- 63 Unique Paths IIFollow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1
2016-09-07 16:35:28
292
原创 LeetCode 13 -- Roman to Integer
LeetCode 13 -- Roman to IntegerGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999Subscribe to see which companies asked this question
2016-09-05 19:54:47
212
原创 Leetcode 3--Longest Substring Without Repeating Characters
Leetcode 3--Add Two NumbersGiven a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3
2016-09-05 18:40:37
188
原创 Leetcode 2--Add Two Numbers
Leetcode 2 :Add Two NumbersYou are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two
2016-09-05 10:33:17
267
原创 Leetcode 1 -- Two Sum
Leetcode 1 -- Two SumGiven 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.Exa
2016-09-05 09:26:57
250
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人