BOJ-algorithm