2 cases not passing. Code running fine on leetcode

import java.util.*;
public class Main {
public static void main (String args[]) {

    Scanner sc = new Scanner(System.in);
    int len=sc.nextInt();

    int nums[]= new int[len];

    for(int i=0; i<len; i++){
        nums[i]= sc.nextInt();
    }

    productExceptSelf(nums);

}

public static void productExceptSelf(int[] nums) {
    
    int len= nums.length;
    int left[]= new int[len];
    int right[]= new int[len];
    
    left[0]=1;
    right[len-1]=1;
    
    int ans[]= new int[len];
    
    for(int i=1; i<len ; i++){
        left[i]= left[i-1]*nums[i-1];
    }
    
    for(int i=len-2; i>=0 ; i--){
        right[i]= right[i+1]*nums[i+1];
    }
    
    for(int i=0; i<len ; i++){
        ans[i]= left[i]*right[i];
        System.out.print(ans[i]+" ");
    }

}

}

hi @ANUKUL1509
I take doubts only in C++… but your logic seems correct only… try taking long long int instead of int, as constraints are large…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.