Book Version 1.4.8: Divide and conquer solution to buy and sale stock once


Has anyone implemented a divide and conquer solution for the ‘buy and sell stock once’ problem discussed on page 1(book version 1.4.8)?
I implemented an algorithm but it results in Stack overflow on the test cases in EPI judge.

I will share the source code, if required.