divide and conquer solution to minfree