DP problem Longest Increasing subsequence

my solution -https://ide.codingblocks.com/s/123316
question -Find the length of the longest subsequence in a given array of integers such that all elements of the subsequence are sorted in strictly ascending order.

Input Format
The first line contains a single integer n. Next line contains n space separated numbers which are 0<a<10^5

Constraints
0< n< 10^5

Output Format
Print a single line containing a single integer denoting the length of the longest increasing subsequence.

Sample Input
6
50 3 10 7 40 80
Sample Output
4

if i am doing this problem using recursion only one test case passed while using DP my code gives wrong ans
please tell me what is mistake in my DP CODE

your function return only the last value of max(l,k) it is also possible that
there is subsequence which is max but end before
so
To make use of recursive calls, your function must return
two things:

  1. Length of LIS(Longest Increasing subsequence) ending with element arr[n-1]. We use maxend for this purpose
  2. Overall maximum as the LIS may end with an element
    before arr[n-1] actualmax is used this purpose.
    i hope it is clear now

@Saurabh2 i have made some changes to my code but code is not working correctly https://ide.codingblocks.com/s/123498 please check it once again or update my code …

see
your function must return
two things:
Length of LIS(Longest Increasing subsequence) ending with element arr[n-1]. you can use maxend for this purpose
Overall maximum as the LIS may end with an element
before arr[n-1] actualmax is used this purpose.

see the commented part