Write code for finding length of largest monotonically increasing sequence in an array of integers.
Optimize it (not the usual O(n) in worst case, but a better approach in average case).