leetcode系列
文章平均质量分 69
QA静静
脚踏实地,奋勇前进
展开
-
leetcode-Add Digits
题目:给定一个非负整数num, 重复将其各个位数上的数字进行求和操作,直到结果为1-9的数(个位数)为止。比如: 给出num = 38 , 计算过程如下: 3 + 8 = 11 , 1 + 1 = 2, 因为2 为个位数, 返回。要求:在 不用循环或递归的情况下,时间复杂度为O(1) ?一开始,没什么思路,就手动计算几个数看看。输入:1,2,3,4,5,6,7,8,9,原创 2016-04-06 09:19:27 · 340 阅读 · 0 评论 -
leetcode-Best Time to Buy and Sell Stock
121. Best Time to Buy and Sell StockSay 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,原创 2016-04-26 08:43:04 · 912 阅读 · 0 评论 -
leetcode-Single Number
136.Single Number IGiven an array of integers, every element appears twiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implemen原创 2016-04-25 20:17:47 · 305 阅读 · 0 评论 -
leetcode-Remove Elements
283. Move ZeroesGiven 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], a原创 2016-04-20 21:40:19 · 368 阅读 · 0 评论 -
【leetcode】238. Product of Array Except Self
题目:Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(原创 2016-05-16 21:13:59 · 265 阅读 · 0 评论 -
【leetcode】268. Missing Number
题目:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums = [0, 1, 3] return 2.Note:Your algorithm should原创 2016-05-17 15:39:36 · 280 阅读 · 0 评论