
leetcode
文章平均质量分 66
yiayia070614
在阿里做苹果业务
展开
-
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 · 299 阅读 · 0 评论 -
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 · 271 阅读 · 0 评论 -
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 · 258 阅读 · 0 评论 -
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 · 266 阅读 · 0 评论 -
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 · 253 阅读 · 0 评论 -
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 · 270 阅读 · 0 评论 -
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 · 193 阅读 · 0 评论 -
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 · 214 阅读 · 0 评论 -
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 · 296 阅读 · 0 评论 -
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 · 369 阅读 · 0 评论 -
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 · 483 阅读 · 0 评论 -
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 · 203 阅读 · 0 评论 -
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 · 231 阅读 · 0 评论 -
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 · 223 阅读 · 0 评论 -
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 · 216 阅读 · 0 评论 -
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 · 256 阅读 · 0 评论 -
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 · 185 阅读 · 0 评论 -
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 · 225 阅读 · 0 评论 -
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 · 291 阅读 · 0 评论 -
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 · 216 阅读 · 0 评论