- 博客(75)
- 资源 (6)
- 收藏
- 关注
原创 leetcode 日经贴,Cpp code -Recover Binary Search Tree
Recover Binary Search Tree /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(N
2015-04-29 18:44:42
353
原创 leetcode 日经贴,Cpp code -Recover Binary Search Tree
Recover Binary Search Tree /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(N
2015-04-29 18:15:52
368
原创 leetcode 日经贴,Cpp code -Convert Sorted List to Binary Search Tree
Convert Sorted List to Binary Search Tree /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * };
2015-04-29 15:44:53
340
原创 leetcode 日经贴,Cpp code -Isomorphic Strings
Isomorphic Strings class Solution { public: bool isIsomorphic(string s, string t) { map mp1, mp2; bool valid = true; for (int i = 0; i < s.length() && valid; ++i) {
2015-04-29 15:37:03
294
原创 leetcode 日经贴,Cpp code -Count Primes
Count Primes class Solution { public: int countPrimes(int n) { if (n <= 1) { return 0; } bitset notpr; vector primes; //primes.reserve(60000)
2015-04-28 19:17:02
291
原创 leetcode 日经贴,Cpp code -Integer to Roman
Integer to Roman class Solution { public: string getstring(string base, int v) { string ret = ""; //v in [0, 9] if (v <= 3) { for (int i = 0; i < v; ++i) {
2015-04-28 16:10:02
380
原创 leetcode 日经贴,Cpp code -Roman to Integer
Roman to Integer class Solution { public: int getvalue(char ch) { int val = 0; switch (ch) { case 'I': val = 1; break; case 'V': val = 5; break;
2015-04-28 15:58:13
311
原创 leetcode 日经贴,Cpp code -Binary Tree Zigzag Level Order Traversal
Binary Tree Zigzag Level Order Traversal /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(
2015-04-28 15:49:23
308
原创 leetcode 日经贴,Cpp code -Binary Tree Level Order Traversal
Binary Tree Level Order Traversal /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL),
2015-04-28 15:47:01
302
原创 leetcode 日经贴,Cpp code -Word Break II
Word Break II class Solution { public: void genvs(const string &s, const vector > &dp, int p, string cs, vector &vs, const vector &valid) { int n = s.length(); if (p == n) {
2015-04-27 16:30:47
396
原创 leetcode 日经贴,Cpp code -Max Points on a Line
Max Points on a Line /** * Definition for a point. * struct Point { * int x; * int y; * Point() : x(0), y(0) {} * Point(int a, int b) : x(a), y(b) {} * }; */ class Solution
2015-04-27 16:14:02
265
原创 leetcode 日经贴,Cpp code -4Sum
4Sum class Solution { public: vector > fourSum(vector &num, int target) { sort(num.begin(), num.end()); vector > vvi; set > sv; unordered_map > > mp; uno
2015-04-26 13:12:24
376
原创 leetcode 日经贴,Cpp code -Letter Combinations of a Phone Number
Letter Combinations of a Phone Number class Solution { public: void genletters(const string &digits, string cur, int indx, vector &vs, string digit2letters[]) { int n = digits.length();
2015-04-26 11:52:17
343
原创 leetcode 日经贴,Cpp code -Single Number II
Single Number II class Solution { public: int singleNumber(vector& nums) { int one = 0, two = 0; for (int i = 0; i < nums.size(); ++i) { int v = nums[i];
2015-04-26 00:03:07
276
原创 leetcode 日经贴,Cpp code -Palindrome Partitioning
Palindrome Partitioning class Solution { private: vector >dp; public: void dfs(const string &s, int n, vector >&vvs, vector &vs) { if (n == s.length()) { vvs.push_b
2015-04-25 23:57:31
279
原创 python multi process download files
import urllib import os from multiprocessing import Process import time def download(url, filename): try: urllib.urlretrieve(url, filename) except Exception: if os.path.isfile(filename):
2015-04-24 23:33:23
533
原创 leetcode 日经贴,Cpp code -Valid Palindrome
Valid Palindrome class Solution { public: bool isPalindrome(string s) { int st = 0, ed = s.length(); if (ed == 0) { return true; } while (st < ed) {
2015-04-24 14:10:39
358
原创 leetcode 日经贴,Cpp code -Clone Graph
Clone Graph /** * Definition for undirected graph. * struct UndirectedGraphNode { * int label; * vector neighbors; * UndirectedGraphNode(int x) : label(x) {}; * }; */ class Solut
2015-04-24 13:55:38
375
原创 leetcode 日经贴,Cpp code -Remove Linked List Elements
Remove Linked List Elements /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solu
2015-04-24 13:54:25
369
原创 python multi-thread download files
import urllib import os import threading import time def download(url, filename): try: urllib.urlretrieve(url, filename) except Exception: os.system('touch ' + filename) print("Failed
2015-04-24 00:49:47
755
原创 leetcode 日经贴,Cpp code -Linked List Cycle II
Linked List Cycle II /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution {
2015-04-22 16:50:27
308
原创 leetcode 日经贴,Cpp code -Linked List Cycle
Linked List Cycle /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { pub
2015-04-22 16:32:06
359
原创 leetcode 日经贴,Cpp code -Evaluate Reverse Polish Notation
Evaluate Reverse Polish Notation class Solution { public: int a2i(const string &s) { int n = 0, neg = 1; for (int i = 0; i < s.length(); ++i) { if (s[i] == '-' && i
2015-04-22 16:27:34
328
原创 leetcode 日经贴,Cpp code -Intersection of Two Linked Lists
Intersection of Two Linked Lists /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class
2015-04-22 16:16:18
286
原创 leetcode 日经贴,Cpp code -Happy Number
Happy Number class Solution { public: int getNext(int n) { int m = 0; while (n) { m += (n % 10) * (n % 10); n /= 10; } vector nums;
2015-04-22 15:32:20
327
原创 leetcode 日经贴,Cpp code -Flatten Binary Tree to Linked List
Flatten Binary Tree to Linked List /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL),
2015-04-21 17:52:34
246
原创 leetcode 日经贴,Cpp code -Binary Tree Inorder Traversal
Binary Tree Inorder Traversal /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), righ
2015-04-21 17:24:07
230
原创 leetcode 日经贴,Cpp code -Same Tree
Same Tree /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */
2015-04-21 17:20:33
342
原创 leetcode 日经贴,Cpp code -Maximum Depth of Binary Tree
Maximum Depth of Binary Tree /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right
2015-04-21 17:17:52
283
原创 leetcode 日经贴,Cpp code -Minimum Depth of Binary Tree
Minimum Depth of Binary Tree /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right
2015-04-21 17:11:44
368
原创 leetcode 日经贴,Cpp code -Path Sum
Path Sum /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */
2015-04-21 17:09:32
313
原创 mac install Scrapy
sudo pip install Scrapy 报错: etree_defs.h:9:10: fatal error: 'libxml/xmlversion.h' file not found sudo C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/
2015-04-21 03:08:18
389
原创 leetcode 日经贴,Cpp code -Longest Consecutive Sequence
Longest Consecutive Sequence class Solution { public: int longestConsecutive(vector &num) { int n = num.size(); if (n <= 1) { return n; } unordered_m
2015-04-20 20:37:35
310
原创 leetcode 日经贴,Cpp code -Binary Tree Maximum Path Sum
Binary Tree Maximum Path Sum /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right
2015-04-20 19:07:01
292
原创 leetcode 日经贴,Cpp code -Single Number
Single Number class Solution { public: int singleNumber(int A[], int n) { int a = 0; for (int i = 0; i < n; ++i) { a ^= A[i]; } return a; } };
2015-04-20 18:31:25
276
原创 leetcode 日经贴,Cpp code -Reorder List
Reorder List /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public:
2015-04-20 18:23:07
306
原创 leetcode 日经贴,Cpp code -Remove Duplicates from Sorted Array II
Remove Duplicates from Sorted Array II class Solution { public: int removeDuplicates(int A[], int n) { if (n <= 1) return n; int m = 1; for (int i = 1; i < n; ++i) {
2015-04-18 17:02:55
292
原创 leetcode 日经贴,Cpp code -Remove Duplicates from Sorted List II
Remove Duplicates from Sorted List II /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */
2015-04-18 16:57:17
324
原创 leetcode 日经贴,Cpp code -Remove Duplicates from Sorted List
Remove Duplicates from Sorted List /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ cla
2015-04-18 16:48:25
263
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人