can any one please tell we whats wrong with sizeof operator here is the code #include #include #include #include using namespace std; int max(int a,int b) { return a>b?a:b; } int longestSeq(int input1[]) { int m=0; int n=sizeof(input1)/sizeof(int); cout<<n<<endl; int lis[n]; for(long long i=0;i<n;i++) { lis[i]=1; } for(long long i=1;i<n;i++) { for(long long j=0;jinput1[j] && lis[i]<lis[j]+1) lis[i]=lis[j]+1; } } for(long long i=0;i<n;i++) { m=max(m,lis[i]); } return m; } int main() { int a[]={10,22,9,33,21,50,41,60,80,100,120}; cout<<longestSeq(a)<<endl; }
Can you specify what problems you are facing.
sizeof is used to find the size in bytes of the structure type provided. You have provided a pointer to a structure which isn’t a type but an instance of a type.