This file contains 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 <deque> | |
#include <algorithm> | |
#include <cstdio> | |
const int MAX_N = 1000 * 1000; | |
int n, w; | |
int a[MAX_N]; | |
int input() { |
This file contains 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
class Solution { | |
public: | |
vector<vector<string>> partition(string s) { | |
vector<vector<string>> results; | |
if (0 == s.size()) { | |
return results; | |
} | |
This file contains 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 <algorithm> | |
#include <string> | |
#include <iostream> | |
#include <iterator> | |
#include <vector> | |
#include <functional> | |
struct person { | |
std::string m_name; | |
int m_age; |
This file contains 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
/** | |
C++ Producer Consumer using C++11 thread facilities | |
To compile: g++ -std=c++11 <program name> -pthread -lpthread -o pc | |
*/ | |
#include <iostream> | |
#include <sstream> | |
#include <vector> | |
#include <stack> | |
#include <thread> | |
#include <mutex> |
This file contains 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 <algorithm> | |
#include <cstdio> | |
#include <deque> | |
#define MAX_N 100000 | |
int n; | |
int h[MAX_N + 1]; | |
struct Node { |
This file contains 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 <vector> | |
#include <algorithm> | |
int nums[] = { 1, 5, 1, 2, 4, 5, 3, 6, 7, 9, 8 }; | |
const int N = sizeof(nums) / sizeof(nums[0]); | |
// partition the array[fromIdx, toIdx] into 2 parts, | |
// where the left is < nums[pivotIdx], the right is >= nums[pivotIdx], | |
// return the final index of the pivot item |
This file contains 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 <cstdio> | |
#include <algorithm> | |
const int MAX_N = 1000; | |
int n; | |
int a[MAX_N]; | |
int input() { | |
scanf("%d", &n); |
This file contains 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 <stack> | |
#ifndef BINARY_TREE_ITERATOR | |
#define BINARY_TREE_ITERATOR | |
/* | |
class Node { | |
public: | |
Node* left(); | |
Node* right(); |
This file contains 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
#!/usr/bin/env node | |
function empty() { | |
return null | |
} | |
function singleton(e) { | |
return { | |
first : function() { return e }, | |
rest : function() { return null } |
This file contains 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
#!/usr/bin/env node | |
function empty() { | |
return null | |
} | |
function singleton(e) { | |
return function() { | |
return { | |
first : e, |