Skip to content

Instantly share code, notes, and snippets.

View joybro's full-sized avatar

Young Lee joybro

  • Coupang.com
  • Seoul, Korea
View GitHub Profile
@joybro
joybro / Makefile
Last active August 29, 2015 14:18 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
// http://codercareer.blogspot.kr/2013/12/no-50-numbers-appearing-once.html
#include <assert.h>
#include <math.h>
#include <string.h>
#include <vector>
#define MAX_BIT 100
void countBits(int *counter, int number) {
// http://codercareer.blogspot.kr/2013/02/no-37-missing-number-in-array.html
// Problem #2
#include <assert.h>
int findMissingNumber(int *array, int start, int end) {
if (array[end] == end) return end + 1;
if (start == end) return end;
int mid = (start + end) / 2;
// A solution for http://codercareer.blogspot.kr/2011/09/no-03-maximum-sum-of-all-sub-arrays.html
// It is assumed that there is at least one positive number in the array.
#include <algorithm>
#include <assert.h>
#include <string.h>
#define LEN 10
int cache[LEN];
// http://www.geeksforgeeks.org/majority-element/
// It is assumed that all numbers in array are positive.
#include <assert.h>
int count(int *array, int start, int end, int num) {
int c = 0;
for (int i = start; i <= end; i++) {
if (array[i] == num) c++;
// http://www.geeksforgeeks.org/topological-sorting/
#include <stdio.h>
#include <vector>
class Graph {
public:
Graph(int nodes) :
nodeCount(nodes) {
edges = new std::vector<int>[nodes];
// http://www.geeksforgeeks.org/check-if-a-given-binary-tree-is-complete-tree-or-not/
#include <assert.h>
#include <queue>
class Node {
public:
Node(int v)
: value(v),
left(0),
// http://www.geeksforgeeks.org/longest-palindrome-substring-set-1/
#include <assert.h>
#include <string.h>
#define MAX_LEN 100
bool cache[MAX_LEN][MAX_LEN];
int length_pal(const char *str) {
// http://www.geeksforgeeks.org/longest-palindromic-substring-set-2/
#include <algorithm>
#include <assert.h>
#include <string.h>
int length_pal(const char *str) {
int len = strlen(str);
int maxlen = 1;
// http://codercareer.blogspot.kr/2013/02/no-44-maximal-stolen-values.html
#include <algorithm>
#include <assert.h>
#include <cstring>
#define MAX_CACHE 100
int maxStolenValueUtil(const int *values, int length, int idx, int *cache) {
if (idx >= length) return 0;