Skip to content

Instantly share code, notes, and snippets.

View huklee's full-sized avatar

Hyeonguk Lee (Huk) huklee

View GitHub Profile
@huklee
huklee / stl_priority_queue_example.cpp
Last active March 6, 2017 12:02
[C++ STL] priority_queue example
#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) {;}
@huklee
huklee / stl_list_example.cpp
Created March 3, 2017 10:51
[C++ STL] double linked list example
#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);
@huklee
huklee / stl_vector_example.cpp
Created March 3, 2017 10:51
[C++ STL] vector (dynamic array) example
#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)
@huklee
huklee / stl_unordered_map_example.cpp
Last active June 13, 2018 03:33
[C++ STL] unordered_map (hash table) example
#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>{
@huklee
huklee / DP_algospot.cpp
Last active March 6, 2017 12:02
algospot_DIAMONDPATH_solution
#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,};
@huklee
huklee / threadPoolTest.py
Last active March 6, 2017 12:03
multi-processes pool worker test
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")
@huklee
huklee / singleton.cpp
Last active February 11, 2017 01:37
Design pattern : singleton, simple implementation in cpp
#include <iostream>
using namespace std;
class Singleton{
private:
static Singleton *u_instance;
int value;
Singleton(int val) : value(val) {};
~Singleton(){};