Solving Longest Increasing Subsequence in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

Given an unsorted array of integers, find the length of longest increasing subsequence.

Example:

Input: [10,9,2,5,3,7,101,18]
Output: 4 
Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4.

Note:

  • There may be more than one LIS combination, it is only necessary for you to return the length.
  • Your algorithm should run in O(n^2) complexity.
    len = 1   :      [4], [5], [6], [3]   => tails[0] = 3
    len = 2   :      [4, 5], [5, 6]       => tails[1] = 5
    len = 3   :      [4, 5, 6]            => tails[2] = 6

See the full details of the problem Longest Increasing Subsequence at LeetCode

Originally posted at: @github.com/halfrost/LeetCode-Go