- 博客(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 345
原创 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 360
原创 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 330
原创 leetcode 日经贴,Cpp code -Isomorphic Strings
Isomorphic Stringsclass 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 286
原创 leetcode 日经贴,Cpp code -Count Primes
Count Primesclass Solution {public: int countPrimes(int n) { if (n <= 1) { return 0; } bitset notpr; vector primes; //primes.reserve(60000)
2015-04-28 19:17:02 274
原创 leetcode 日经贴,Cpp code -Integer to Roman
Integer to Romanclass 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 350
原创 leetcode 日经贴,Cpp code -Roman to Integer
Roman to Integerclass 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 296
原创 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 296
原创 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 293
原创 leetcode 日经贴,Cpp code -Word Break II
Word Break IIclass 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 384
原创 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 256
原创 leetcode 日经贴,Cpp code -4Sum
4Sumclass 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 354
原创 leetcode 日经贴,Cpp code -Letter Combinations of a Phone Number
Letter Combinations of a Phone Numberclass 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 327
原创 leetcode 日经贴,Cpp code -Single Number II
Single Number IIclass 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 263
原创 leetcode 日经贴,Cpp code -Palindrome Partitioning
Palindrome Partitioningclass 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 267
原创 python multi process download files
import urllibimport osfrom multiprocessing import Process import timedef download(url, filename): try: urllib.urlretrieve(url, filename) except Exception: if os.path.isfile(filename):
2015-04-24 23:33:23 500
原创 leetcode 日经贴,Cpp code -Valid Palindrome
Valid Palindromeclass 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 335
原创 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 365
原创 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 349
原创 python multi-thread download files
import urllibimport osimport threadingimport timedef download(url, filename): try: urllib.urlretrieve(url, filename) except Exception: os.system('touch ' + filename) print("Failed
2015-04-24 00:49:47 724
原创 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 290
原创 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 333
原创 leetcode 日经贴,Cpp code -Evaluate Reverse Polish Notation
Evaluate Reverse Polish Notationclass 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 304
原创 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 260
原创 leetcode 日经贴,Cpp code -Happy Number
Happy Numberclass 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 302
原创 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 230
原创 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 220
原创 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 326
原创 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 272
原创 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 353
原创 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 294
原创 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 365
原创 leetcode 日经贴,Cpp code -Longest Consecutive Sequence
Longest Consecutive Sequenceclass Solution {public: int longestConsecutive(vector &num) { int n = num.size(); if (n <= 1) { return n; } unordered_m
2015-04-20 20:37:35 279
原创 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 279
原创 leetcode 日经贴,Cpp code -Single Number
Single Numberclass 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 261
原创 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 288
原创 leetcode 日经贴,Cpp code -Remove Duplicates from Sorted Array II
Remove Duplicates from Sorted Array IIclass 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 268
原创 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 303
原创 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 240
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人