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
import piexif | |
import pickle | |
from PIL import Image | |
def saveExifFromPickle(exif_dict, outFile): | |
pickle.dump(exif_dict, open(outFile, "wb")) | |
def loadExifFromPickle(inFile): | |
return pickle.load(open(inFile, "rb")) |
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
# 1) using Min-Heap logN | |
# 1. make a min heap(Heap Queue : python heapq) S with sum value | |
# 2. pick first Elem in S and j++ then, push it again | |
# 3. iterate k times till every j < len(b) | |
# T(n) = O(klogN) | |
from heapq import * | |
class Solution: |
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
import functools | |
def sorted_by(a,b): | |
if a[0] == b[0]: | |
return a[1] - b[1] | |
else: | |
return a[0] - b[0] | |
cmp = functools.cmp_to_key(sorted_by) |
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
class Tree(): | |
def __init__(self, val): | |
self.val = val | |
self.child = [] | |
def addChild(self, t): | |
children = self.child | |
children.append(t) | |
def print(self, lev = ""): |
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
# -*- coding: utf-8 -*- | |
import logging | |
import os | |
import datetime | |
import time | |
class SingletonType(type): | |
_instances = {} |
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 <bits/stdc++.h> | |
// #include <iostream> | |
// #include <cstdio> | |
// #include <cstring> | |
// #include <cmath> | |
// #include <algorithm> | |
// #include <stack> | |
// #include <queue> | |
// #include <set> | |
// #include <map> |
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
#ifndef cimg_plugin | |
#define cimg_plugin " " | |
#include "CImg.h" | |
using namespace cimg_library; | |
#ifndef cimg_imagepath | |
#define cimg_imagepath "img/" | |
#endif |
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> | |
using namespace std; | |
// bitwise operation solution | |
void solve(string s){ | |
// assert (s.size() <= 32); | |
for (int i=1; i < (1 << s.size()); i++){ | |
string result; | |
for (int j=0; j < s.size(); j++){ |
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
// author : huklee | |
// source : JTD 2017-03-05 | |
// print all combinations of string 2D list | |
#include <vector> | |
#include <string> | |
#include <iostream> | |
using namespace std; | |
string print_combination(vector<int> &index_list, vector<vector<string> > &v){ |
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
# author : huklee | |
# source : JTD 2017-03-05 | |
# print all combinations of string 2D array | |
def printComb(a, sl): | |
s = "" | |
for i in range(len(a)): | |
s += sl[i][a[i]] | |
return s |
NewerOlder