|  | 
|  | 
| back to board | TLE can u reduce time its not clicking? import java.io.*;import java.util.*;
 
 public class LargeSum_1048{
 
 
 public static void main(String args[]) throws IOException
 {
 BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
 
 String temp=new String(buf.readLine());
 int n=Integer.parseInt(temp);
 
 
 
 int total=n*5;
 int k=total-3;
 total=total+20;
 
 char input[]=new char[total];
 
 
 buf.read(input,0,total);
 
 
 
 
 int sum=0,carry=0,i;
 String str=new String();
 
 
 
 for(i=0;i<n;i++)
 {
 
 
 sum=input[k]+input[k-2]-96+carry;
 
 
 k=k-5;
 
 if(sum>9)
 {
 carry=1;
 sum=sum-10;
 }
 else{
 carry=0;
 }
 
 str=sum+str;
 }
 
 System.out.println(str);
 
 
 
 
 }
 }
There is a solution without arrays, with O(1) memory | 
 | 
|