- 博客(11)
- 收藏
- 关注
原创 LeetCode-14
class Solution { public: string longestCommonPrefix(vector<string>& strs) { string s = ""; if(strs.size() == 0) return ""; for(int i=0; i<strs[0].l...
2018-03-15 21:37:40
93
原创 LeetCode-11
class Solution { public: int maxArea(vector<int>& height) { int l = 0, r = height.size()-1; int vol, vol_max = min(height[l],height[r])*(r-l); while(l < r) ...
2018-03-14 14:53:06
121
原创 LeetCode-13
class Solution(object): def romanToInt(self, s): """ :type s: str :rtype: int """ sum = 0 pre = 2000 cur = 0 Map = {'I':1,'V':5,'X':...
2018-03-13 21:43:02
101
原创 LeetCode-5
class Solution { public: string longestPalindrome(string s) { int bound = 0; int id, max_pos = 0; int new_len = 2*s.length() + 2; vector<int> P(new_len, 1); ...
2018-03-12 16:08:38
128
原创 LeetCode-8
class Solution { public: int myAtoi(string str) { int sign = 1, base = 0, i = 0; while(str[i] == ' '){ i++; } if(str[i]=='-' || str[i]=='+'){ sign = 1-2*(str[i+...
2018-03-09 16:45:32
187
原创 LeetCode-9
class Solution { public: bool isPalindrome(int x) { if(x<0 || (x!=0 && x%10==0)){ return false; } int r = 0; while(r < x){ r =...
2018-03-08 21:54:32
115
原创 LeetCode-6
class Solution { public: string convert(string s, int numRows) { string str[numRows],tmp; if(numRows == 1){ return s; } int flag; for(int i = 0,...
2018-03-07 20:04:13
103
原创 LeetCode-7
class Solution { public: int reverse(int x) { int result = 0; while(x != 0){ int tail = x % 10; int newResult = result*10 + tail; if((newResult ...
2018-03-06 21:32:03
94
原创 LeetCode-2
class Solution { public: ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { ListNode* sentinel = new ListNode(0); ListNode* d = sentinel; int sum = 0; while(l1 !...
2018-03-05 19:08:22
238
原创 LeetCode-3
class Solution { public: int lengthOfLongestSubstring(string s) { map<char,int> m; int maxLen = 0; int lastRepeatPos = -1; for(int i = 0; i < s.size(); i++...
2018-03-01 18:42:32
119
原创 LeetCode-1
class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int,int> m; vector<int> result; for(int i=0; i<num...
2018-03-01 14:26:59
104
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人