摘要: 思路一:递归 思路二:迭代 从头至尾,依次反转相邻节点指针 阅读全文
posted @ 2017-04-09 21:48 蓦然闻声 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 121. Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitte 阅读全文
posted @ 2017-04-09 21:47 蓦然闻声 阅读(72) 评论(0) 推荐(0) 编辑
摘要: 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 day i. Design an algorithm to 阅读全文
posted @ 2017-04-09 21:47 蓦然闻声 阅读(76) 评论(0) 推荐(0) 编辑
摘要: 167. Two Sum II - Input array is sorted Given an array of integers that is already sorted in ascending order, find two numbers such that they add up t 阅读全文
posted @ 2017-04-09 21:46 蓦然闻声 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 思路:罗马计数转阿拉伯数字。罗马数字的构造:XCVIII表示98,DCXXI表示621。从右至左,用max记录当前最大数的符号,若当前索引处的数字比max大,则将总数加上当前索引字符所代表的的数,如果小,则将总数减去当前索引所代表的数字。 阿拉伯数字转换为罗马计数 思路:罗马数字的基本型为:I = 阅读全文
posted @ 2017-04-09 21:45 蓦然闻声 阅读(307) 评论(0) 推荐(0) 编辑
摘要: A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents 阅读全文
posted @ 2017-04-09 21:44 蓦然闻声 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 217. Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears a 阅读全文
posted @ 2017-04-09 21:42 蓦然闻声 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 350. Intersection of Two Arrays II Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 阅读全文
posted @ 2017-04-09 21:42 蓦然闻声 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 409. Longest Palindrome Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built 阅读全文
posted @ 2017-04-09 21:41 蓦然闻声 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 169. Majority Element Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. Y 阅读全文
posted @ 2017-04-09 21:40 蓦然闻声 阅读(98) 评论(0) 推荐(0) 编辑