Getting compile time error


  • 0
    S

    Hi , I am new to online competitive coding platform , I am getting compile time error

    Line 48: 'n1' does not name a type

    Here is my code , any help would be appreiciated . Thanks in advance

    int a[8]={1,4,5,6,6};

    class NumArray {
    public:

    int aux[100][100];

    int sumRange(int i, int j) {
        
        if(i==j){
            aux[i][j]=a[i];
            
            return a[i];
            
        }
        
        else{
            
            if(aux[i][j] > 0 ) {
                
                return aux[i][j];
                
            }
            
            else {
            
            int temp=sumRange(i,j-1) + a[j];
            
             aux[i][j]=temp;
             
            return temp;
            
            }
            
        }
        
    }
    

    };

    // Your NumArray object will be instantiated and called as such:
    NumArray n1;
    n1.sumRange(0, 1);
    n1.sumRange(1, 2);


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.