Skip to content

Instantly share code, notes, and snippets.

#include <set>
#include <vector>
#include <climits>
#include <iostream>
#include <algorithm>
#include <cassert>
using namespace std;
struct LNode {
int val;
#include <iostream>
#include <string>
namespace __hidden__ {
struct print{
bool space;
print():space(false) { }
~print() { std::cout << std::endl; }
template <typename T>
/*
* counting all objects
*/
class Base {
private:
static size_t _count;
public:
Base() { ++_count; }
~Base() { --_count; }
static size_t getcount() {
/*
uva 439 - Knight Moves
keyword: bfs
*/
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstdio>
/*
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;
/*
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;
/*
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);
/*
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>
/*
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) {}
/*
uva 10282 - Babelfish
run time: 0.268 ms
*/
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>