What is the wrong in this code?

programming

#1

I tried LIS…but something wrong in my code…Please tell me what is the wrong in my code ?


#2

You can use Dynamic Programming to solve this problem efficiently.
My solution for LIS with comments and explaination

//Author Abhishek Kumar
#include<bits/stdc++.h>
#define vi vector
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define vpi vector
#define MAX (int)1e5
#define big (int)1e9+7
#define ll long long
#define si set
#define fast_io ios::sync_with_stdio(false);cin.tie(NULL);
#define f first
#define s second
#define rep(i,a,b) for(int i=a;i<b;i++)
#define reps(i,a,b) for(int i=a;i<=b;i++)
#define ull unsigned long long
using namespace std;

//Longest Increasing subsequence

//Linear DP solution

//Recurrence

//dp*=Longest Increasing subsequence ending at index i

//Thus dp*=1+max(dp[j]) for all j from 1 to i such that a*<=a[j]

// =1 is no such j exists

//Time Complexity O(n^2)

//Space Complexity O(n)

int lis(int *a,int n)
{
int dp[n];

for(int i=0;i<n;i++)
{

int w=0;
for(int j=0;j<i;j++)
{

        if(a[j]<=a*)

            w=max(w,dp[j]);
    }

dp*=1+w;
}

return dp[n-1];
}
int main()
{
int n;

cin>>n;

int *a=new int[n];

rep(i,0,n)

cin>>a*;

cout<<lis(a,n);

}


#3

Can you explain your code. What is n and what is p?


#4

Can you please specify the problem statement.


#5

Longest Increasing Subsequent.


#6

@mathecodician, here n=0 index and p is the number of elements.


#7

Tnq @inovation123.