title: Find longest ascending sequence in an array (Python)
body: <p>You are given an array of numbers, say </p>
  
  <pre><code>nums = [2, 5, 3, 3, 4, 6]
  </code></pre>
  
  <p>And want to get the longest possible sequence of numbers, that are ascending, though not necessarily consequent, while maintaining their order. </p>
  
  <p>So the longest array of numbers where A<sub>n</sub> &lt; A<sub>n+1</sub>. In this case:</p>
  
  <pre><code>[2, 3, 4, 6]
  </code></pre>
  
  <p>I have done this via recursion and loops, testing every possibility. This however takes way too much time for larger arrays and
  so my question is, whether there is a better/faster method to do this.</p>
  
  <p>Thanks in advance!</p>
  
  <p>Here's my previous code, which returned the length of the final array</p>
  
  <pre><code>def bestLine(arr):
      maximum = 0
      for i in range(0, len(arr)):
          if (len(arr)-i &lt; maximum):
              break
          maximum = max(maximum, f(i, len(arr), arr))
      return maximum
  
  def f(start, end, arr):
      best = 0
      for i in range(start+1, end):
          if (end-i &lt; best):
              break
          if (arr[i] &gt; arr[start]):
              best = max(best, f(i, end, arr))
      return 1 + best
  </code></pre>