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 <queue> | |
using namespace std; | |
class Node{ | |
public: | |
int val; | |
Node* left; | |
Node* right; | |
Node (int v, Node *l, Node *r) : val(v), left(l), right(r) {;} |
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 <list> | |
#include <vector> | |
#include <unordered_map> | |
void std_list_test(){ | |
std::cout << "=== std::list Test ===" << std::endl; | |
std::list<int> li; | |
li.push_back(2); | |
li.push_back(3); |
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 <vector> | |
void std_vector_test(){ | |
std::cout << "=== std::vector Test ===" << std::endl; | |
// 01. assignemnt | |
std::vector<int> v1; | |
v1.reserve(20); // assign the memory space of 20 * int | |
std::vector<int> v2(2); // assign the memory & fill 2*null(0) |
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> | |
#include <unordered_map> | |
// how to make a new datatype in hashtable | |
struct X{int i,j,k;}; | |
namespace std { | |
template <> | |
class hash<X>{ |
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 <vector> | |
using namespace std; | |
// DP solution | |
int solve (vector< vector<int> > &grid){ | |
// edge case | |
int m=grid.size(), n=grid[0].size(); | |
int DP[101][101] = {0,}; |
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
from multiprocessing.dummy import Pool as ThreadPool | |
import time | |
class timer: | |
def timerStart(self): | |
self.start = time.time() | |
def timerEnd(self): | |
self.end = time.time() | |
print(str(self.end - self.start),"sec elapsed") |
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> | |
using namespace std; | |
class Singleton{ | |
private: | |
static Singleton *u_instance; | |
int value; | |
Singleton(int val) : value(val) {}; | |
~Singleton(){}; |
NewerOlder