Solution for Foregone solution in Qualification Round 2019 - Google Code
Jam 2019 giving runtime error can anybody please help me?
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
//import java.io.File;
class CC {
//Qualification Round 2019 - Google Code Jam 2019== foregone solution
public static void main(String[] args) throws NumberFormatException,
IOException {
//File file = new File("C:\\Users\\rv602\\Desktop\\input1.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//ArrayList<Integer> al = new ArrayList<>();
int t = Integer.parseInt(br.readLine().trim());
String s,ans2,ans1,answer="";
int flag;
for (int t1 = 0; t1 < t; ++t1) {
s = br.readLine().trim();
ans1 = "";
ans2 = "";
flag=0;
for (int i = 0; i < s.length(); ++i) {
char ch=s.charAt(i);
if(ch=='4')
{
ans1=ans1+"2";
ans2=ans2+"2";
flag=1;
}
else
{
ans1+=Character.toString(ch);
if(flag==1)
ans2+="0";
}
}
answer+="Case #"+(t1+1)+": "+ans1+" "+ans2+'\n';
}
System.out.println(answer);
}
}
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/bde6816e-b795-414e-a82c-385a89f4e1a9%40googlegroups.com.