Different approach

what the array is made with such complexity

// 2-D array Scanning

	for(int i=0; i<rows;i++) {
		for(int j=0;j<col;j++) {
			arr[i][j] = sc.nextInt();
		}
	}

what is the issue with the above code

@ishaanveerd we do not have the same number of columns for each row. that is why we are taking no of col input for each row separately
for example for a zig zag array like
1 2
3 4 5 6
7 8 9
your code wont work

please mark your doubt as resolved if u are satisfied with the solution