error: use of undeclared identifier 'Solution' vector<int> ret = Solution().plusOne(param_1); return ret;

7.9k Views Asked by At

trying to add +1 to the nth term****and showing the error at the leetcode window which is mentioned above

     #include<iostream>

     using namespace std;
     int main()
   {
         int n;
         int a[n];//array of n number
         cin>>n;
      for(int i=0;i<n;i++)
     {
        cin>>a[i];
     }
      for(int i=0;i<n;i++)
    {
      if(a[i+1]==a[n]) //I am trying to add +1 to nth term of array
        {
                a[i]=a[i]+1;
        
         }
        cout<<a[i];
          }
         return 0;
        }
1

There are 1 best solutions below

0
Pratik Tushar Cholke On

Basically I think you might have erased all the code in leetcode window and pasted the above code in it. You might have erased "*** Class Solution{ public: }; ***" part of the console. Try to reset your code and paste your solution(which includes only the function) only under public section of the class. It should work fine.