How to take an array of size<=10^8 as input and perform operations on it?
arr[i]<=10^8
.
The below code gives runtime error and java.lang.OutOfMemoryError.
I have got this question multiple times and never got the answer as it gives error for large values of n and arr[i]
.
I know that it can't be done in the way given below. So the question is, how can it be done in Java ?
n=100000000;//User input
int[] arr=new int[n];
int[] b=new int[n];
for(int i=0;i<n;i++)
{
b[i]=arr[i]+1;
}