One way to engage with this problem would be to reduce it to searching of sub-arrays. Because here our aim is to simply identify and sum up *increasing* sequences within a larger array. Basically, if we visualize a plotted graph of stock prices, then all the values within the rising curves would be of our interest.

```
int maxProfit(int* p, int pSize)
{
return (pSize > 1) ? (p[1] - p[0] > 0 ? p[1] - p[0] + maxProfit(&p[1], pSize - 1) : maxProfit(&p[1], pSize - 1)) : 0;
}
```