摘要: Compare two version numbersversion1andversion2.Ifversion1>version2return 1, ifversion1sum2)return 1;16 else if(sum1<sum2)return -1;17 ... 阅读全文
posted @ 2015-08-08 21:10 irun 阅读(113) 评论(0) 推荐(0) 编辑
摘要: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes... 阅读全文
posted @ 2015-08-08 20:14 irun 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 12- Integer to RomanGiven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Solution: 枚举,考虑每个字符以及每两个... 阅读全文
posted @ 2015-08-08 00:05 irun 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 66 - Plus OneGiven a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significan... 阅读全文
posted @ 2015-08-06 23:38 irun 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 168 - Excel Sheet Column TitleGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 ... 阅读全文
posted @ 2015-08-06 23:05 irun 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.Solution :计算包含的2和5组成的pair的个数,... 阅读全文
posted @ 2015-08-05 17:59 irun 阅读(116) 评论(0) 推荐(0) 编辑
摘要: Rotate an array ofnelements to the right byksteps.For example, withn= 7 andk= 3, the array[1,2,3,4,5,6,7]is rotated to[5,6,7,1,2,3,4].Note:Try to come... 阅读全文
posted @ 2015-08-04 22:53 irun 阅读(326) 评论(0) 推荐(0) 编辑
摘要: 190 - Reverse BitsReverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as000000101001010000011110... 阅读全文
posted @ 2015-08-04 00:06 irun 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 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 yo... 阅读全文
posted @ 2015-08-03 23:28 irun 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2015-08-02 21:56 irun 阅读(120) 评论(0) 推荐(0) 编辑