Skip to content

Instantly share code, notes, and snippets.

@luckypapa
luckypapa / findIntersectionFromSortedArray.cpp
Created July 12, 2015 08:10
No. 24 - Intersection of Sorted Arrays
//http://codercareer.blogspot.kr/2011/11/no-24-intersection-of-sorted-arrays.html
//timecomplexity : O(nlogm)
//spacecompexity : O(n)?
#include <vector>
#include <iostream>
#include <algorithm>
int arr1[7] = {1, 3, 5, 7, 9, 10, 15};
int arr2[5] = {3, 5, 7, 11, 16};
@luckypapa
luckypapa / xornecklace.c
Last active August 29, 2015 14:25
XOR Necklace
// A ^ B = A + B - 2(A&B) .....
// https://algospot.com/judge/problem/read/XORNECKLACE
// time complexity : O(n)
// space complexity : O(500)
#include <stdio.h>
#define MAX_SIZE 500
long long int xorNeclaceMaxValue(void) {
@luckypapa
luckypapa / coins.cpp
Created August 3, 2015 14:15
COINS SOLUTION
//https://algospot.com/judge/problem/read/COINS
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#define MAX_COINS 100
#define MAX_EXCHANGE 5000
#define OVER_CASE 1000000007
@luckypapa
luckypapa / bridge_link.cpp
Created August 6, 2015 07:14
Bridge Link solution
@luckypapa
luckypapa / fibonacci.cpp
Created August 20, 2015 15:13
fibonacci_get_zero_one
//https://www.acmicpc.net/problem/1003
#include<stdio.h>
typedef struct CACHE{
unsigned long long zero;
unsigned long long one;
} CACHE_T;
static CACHE_T cache[41] = {0};
//https://www.acmicpc.net/problem/1004
#include <stdio.h>
#define SQUARE(X) (X)*(X)
typedef struct{
int x;
int y;
int r;
//https://www.acmicpc.net/problem/3059
#include <stdio.h>
#define TOTAL_UPPER_ASCI 2015
int getSumOfNoneChar(void) {
int data[26] = { 0 };
int sum = TOTAL_UPPER_ASCI;
char temp[1000] = { 0 };
//https://www.acmicpc.net/problem/1009
#include <stdio.h>
int cache[8][4] = {
{2,4,8,6},
{3,9,7,1},
{4,6,4,6},
{5,5,5,5},
{6,6,6,6},
//https://algospot.com/judge/problem/read/SNAIL
//timecomplexity : O(2m-n)
#include <stdio.h>
#include <math.h>
/*
int factorial(int a) {
int result = 1;
for (int i = a; i >= 1; i--) {
result *= i;
@luckypapa
luckypapa / trianglepath.cpp
Created September 20, 2015 07:41
solution of TRIANGLEPATH
//https://algospot.com/judge/problem/read/TRIANGLEPATH
#include <iostream>
#include <memory.h>
#include <algorithm>
using namespace std;
int triangle[101][101];
int cache[101][101];
int N;