LeetCode
Alcyone_1207
这个作者很懒,什么都没留下…
展开
-
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论