- 博客(10)
- 收藏
- 关注
原创 LeetCode OJ 14 Longest Common Prefix
题目: Write a function to find the longest common prefix string amongst an array of strings. 难度: Easy 思路: 从头开始比较每个字符串,不等就停止循环即可 代码如下 class Solution { public: string longestCommonPrefix(vecto
2015-10-21 07:26:02 403
转载 LeetCode OJ 13 Roman To Integer
参考http://blog.csdn.net/jellyyin/article/details/13165731 代码如下class Solution { public: int romanToInt(string s) { map mapValue; mapValue.insert(pair('I',1)); mapValue.inser
2015-10-21 07:13:10 402
原创 LeetCode OJ 12 Integer to Roman
题目: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 难度: medium 思路: 找到罗马数字对应阿拉伯数字的规律即可。将数字对应序列从大到小排列,每次减掉可以减掉的最大数,换成对应的罗马字母即可
2015-10-21 06:35:18 546
原创 LeetCode OJ 11 Container With Most Water
题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i,
2015-10-21 06:16:45 437
原创 LeetCode OJ 9 Palindrome Number
题目: Determine whether an integer is a palindrome. Do this without extra space. 难度 easy 思路:每一个提取最高位和最低位进行比较即可 代码如下 using namespace std; class Solution { public: bool isPalindrome(int x) {
2015-10-21 01:28:06 429
转载 LeetCode OJ 123 Best Time to Buy and Sell Stock III
题目: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most k transactions. Note: Y
2015-10-21 01:07:43 471
原创 LeetCode OJ 123 Best Time to Buy and Sell Stock III
题目: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transactions. Note:
2015-10-20 01:13:02 489
原创 LeetCode OJ 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 permitted to complete at most one transaction (ie, buy one and sell one share of th
2015-10-19 12:33:20 423
原创 LeetCode OJ 198 House Robber
题目: 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 you from robbing each of them is that adjac
2015-10-18 00:32:35 482
原创 LeetCode OJ 05 Longest Palindromic Substring
题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 难度:medium
2015-10-13 23:42:17 419
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人