算法
cyclone_li
小菜鸟一枚
展开
-
【LeetCode】MouseCode
#include<iostream> #include<string> #include<vector> using namespace std; class Solution { public: int uniqueMorseRepresentations(vector<string>& words) { string s[26]...原创 2018-04-02 22:23:37 · 121 阅读 · 0 评论 -
【LeetCode-807】Max Increase to Keep City Skyline
#include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; class Solution { public: int maxIncreaseKeepingSkyline(vector<vector<in...原创 2018-04-02 22:37:29 · 141 阅读 · 0 评论 -
【LeetCode-11】盛最多水的容器
class Solution { public: int maxArea(vector<int>& height) { int left = 0; int right = height.size()-1; int maxValue = 0; while(left<right){ ...转载 2018-04-02 23:20:05 · 129 阅读 · 0 评论 -
【LeetCode-2】两数相加
class Solution { public: ListNode *addTwoNumbers(ListNode *l1, ListNode *l2) { ListNode preHead(0), *p = &preHead; int carry = 0; while (l1 || l2 || carry) { int sum = (l1 ? l1...转载 2018-04-03 22:35:48 · 145 阅读 · 0 评论 -
【LeetCode】字符串转整数(atoi)
class Solution { public: int myAtoi(string str) { int i = 0, base = 0, sign = 1; while (str[i] == ' '&&i<str.size()) { i++; } if (str[i] == '-' || str[i] == '+') { str[i]...原创 2018-04-03 23:16:45 · 142 阅读 · 0 评论 -
【LeetCode10】正则表达式匹配
转自:点击打开链接class Solution { public: bool isMatch(string s, string p) { if (p.empty()) return s.empty(); if (p.size() > 1 && p[1] == '*') { return isMatch(s, p....转载 2018-04-03 23:32:48 · 145 阅读 · 0 评论 -
【LeetCode-11】盛水最多的容器
class Solution { public: int maxArea(vector<int>& height) { int i,a=0,b=height.size()-1,volumn=0; for (i = 0; a<b && i<height.size(); i++) { int minValue = min(he...原创 2018-04-04 23:18:48 · 180 阅读 · 0 评论 -
【LeetCode-23】合并K个元素的有序链表
用了最笨的办法,遍历一次取出所有元素排序,生成新链表,没想到通过了~/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class ...原创 2018-04-06 19:56:45 · 214 阅读 · 0 评论