brute force & greedy

brute force algorithm still has a bug.