摘要: /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public ListNode reverseKGr... 阅读全文
posted @ 2018-02-03 22:44 nosaferyao 阅读(110) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: ListNode* mergeKLists(vector& lists) { ListNode* head = NULL; ListNode* current = NULL; for (int i = 0; i val; int min_index = 0; ... 阅读全文
posted @ 2017-11-27 21:24 nosaferyao 阅读(110) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* m... 阅读全文
posted @ 2017-11-27 21:12 nosaferyao 阅读(168) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: vector> threeSum(vector& nums) { sort(nums.begin(), nums.end()); vector > validSet; for (int i = 0; i = 1 && nums[i] == nums[i-1])continu... 阅读全文
posted @ 2017-11-27 20:57 nosaferyao 阅读(152) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: vector> threeSum(vector& nums) { sort(nums.begin(), nums.end()); vector > validSet; for (int i = 0; i = 1 && nums[i] == nums[i-1])continue... 阅读全文
posted @ 2017-11-19 21:55 nosaferyao 阅读(116) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int myAtoi(string str) { int index = -1; int result = 0; int base = 10; int ssize = str.size(); bool negtive = false; whil... 阅读全文
posted @ 2017-11-18 21:07 nosaferyao 阅读(135) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: bool match(string s, string p, int ss, int ps){ int psize = p.size(); int ssize = s.size(); while (ps < psize && ss < ssize){ char c = p[ps]; if (c != '.'... 阅读全文
posted @ 2017-11-18 19:34 nosaferyao 阅读(116) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: bool isPalindrome(int x) { int ret = 0; while (x > ret){ int remainder = x % 10; if (remainder == 0 && ret == 0){ ... 阅读全文
posted @ 2017-09-17 21:48 nosaferyao 阅读(124) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int reverse(int x) { int ret = 0; int int_max_divide_10 = INT_MAX / 10; int int_max_mod_10 = INT_MAX % 10; int int_min_divide_10 = INT_MIN / 10; i... 阅读全文
posted @ 2017-09-16 17:28 nosaferyao 阅读(212) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: string convert(string s, int numRows) { if (numRows == 1){ return s; } string out; for (int i = 0; i = (in... 阅读全文
posted @ 2017-09-10 23:15 nosaferyao 阅读(155) 评论(0) 推荐(0) 编辑