I am getting wrong-answer, run-error and wrong-answer for test case :1,2 and 4 repectively

public static void calSumUtil(int a[], int b[], int n, int m) {
int[] sum = new int[n];
int i = n - 1, j = m - 1, k = n-1;
int carry = 0, s = 0;
while (j >= 0) {
s = a[i] + b[j] + carry;
sum[k] = (s % 10);
carry = s / 10;
k–;
i–;
j–;
}
while (i >= 0) {

		s = a[i] + carry;
		sum[k] = (s % 10);
		carry = s / 10;
		i--;
		k--;
	}

	if (carry == 1) {
		int [] sumc= new int [n+1];
		sumc[0]=1;
		for(int kk=0;kk<sum.length;kk++) {
			sumc[kk+1]=sum[kk];
		}

		
		for (int z = 0; z < sumc.length; z++) {
			System.out.print(sumc[z] + ", ");
		}
	}
	else {
		for (int z = 0; z < sum.length; z++) {
			System.out.print(sum[z] + ", ");
		}
	}
	System.out.print("END");

}

static int calSum(int a[], int b[], int n, int m) {
	if (n >= m)
		calSumUtil(a, b, n, m);
	else
		calSumUtil(b, a, m, n);
	return 0;
}

public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int m = s.nextInt();
	int n = s.nextInt();
	int[] a = new int[m];
	int[] b = new int[n];
	for (int i = 0; i < m; i++) {
		a[i] = s.nextInt();
	}
	for (int i = 0; i < n; i++) {
		b[i] = s.nextInt();
	}
	calSum(a, b, m, n);
	s.close();

}

}

Hi @Anshuman-Behera-1168641663271515

First, run your code for sample Input/Output. Your code doesn’t work right that test case.

Hi Anshuman

As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.

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.