This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <set> | |
| #include <vector> | |
| #include <climits> | |
| #include <iostream> | |
| #include <algorithm> | |
| #include <cassert> | |
| using namespace std; | |
| struct LNode { | |
| int val; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| namespace __hidden__ { | |
| struct print{ | |
| bool space; | |
| print():space(false) { } | |
| ~print() { std::cout << std::endl; } | |
| template <typename T> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * counting all objects | |
| */ | |
| class Base { | |
| private: | |
| static size_t _count; | |
| public: | |
| Base() { ++_count; } | |
| ~Base() { --_count; } | |
| static size_t getcount() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| uva 439 - Knight Moves | |
| keyword: bfs | |
| */ | |
| #include <iostream> | |
| #include <queue> | |
| #include <algorithm> | |
| #include <vector> | |
| #include <cstdio> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| url : http://oj.leetcode.com/problems/clone-graph/ | |
| keyword : hash | |
| keypoint: use map to save the reflection of original pointer and newly created pointer | |
| */ | |
| /** | |
| * Definition for undirected graph. | |
| * struct UndirectedGraphNode { | |
| * int label; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| http://oj.leetcode.com/problems/binary-tree-level-order-traversal/ | |
| keypoint: add sentinal to flag the level end | |
| */ | |
| /** | |
| * Definition for binary tree | |
| * struct TreeNode { | |
| * int val; | |
| * TreeNode *left; | |
| * TreeNode *right; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| url : http://oj.leetcode.com/problems/palindrome-partitioning/ | |
| keyword : backtracking | |
| */ | |
| class Solution { | |
| public: | |
| vector<vector<string>> partition(string& s) { | |
| // Note: The Solution object is instantiated only once and is reused by each test case. | |
| vector<vector<string>> ans; | |
| solve(s, 0, s.length(), vector<string>(), ans); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=111&problem=1066&mosmsg=Submission+received+with+ID+12456504 | |
| uva 10125 | |
| keyword: hash | |
| */ | |
| #include <cstdio> | |
| #include <vector> | |
| #include <map> | |
| #include <iostream> | |
| #include <algorithm> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| http://oj.leetcode.com/problems/copy-list-with-random-pointer/ | |
| */ | |
| /** | |
| * Definition for singly-linked list with a random pointer. | |
| * struct RandomListNode { | |
| * int label; | |
| * RandomListNode *next, *random; | |
| * RandomListNode(int x) : label(x), next(NULL), random(NULL) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| uva 10282 - Babelfish | |
| run time: 0.268 ms | |
| */ | |
| #include <cstring> | |
| #include <cassert> | |
| #include <cstdio> | |
| #include <cstdlib> |