Transform and conquer algorithm