+ 1
How can i jump to answer the test case#2 after clearing the 1st one?
In extra terrestrial code challenge i had solved the reverse of 'garbage' but in the next question when i started to write code it got messed up in the first one . Please tell me how to solve them seperately
4 Respuestas
0
Don't pass Hard Code value just take user input.
0
Bro can you explain a little more
0
Kush Kumar Samarth
Every test cases has different inputs and outputs so if you write Hard Code value instead of taking user input then at the time only 1 test cases would be pass.
So you have to take user input and write generic logic which can pass all test cases.
Generic logic means code will be same but output will be depends on inputs.
For example : get sum of 2 numbers
int a = 2; //this is called Hard Code value
int b = 4;
int c = a + b;
System.out.println(c);
2 + 4 = 6
4 + 4 = 8
5 + 5 = 10
See code is same means (a + b)
But output is coming on the basis of input.
int a = scanner.nextInt(); //this is called user input
int b = scanner.nextInt();
int c = a + b;
Now here you dont need to do anything. This code can be run for multiple test cases.
0
Bro i hadn't reached that level so it is hard to understand for me
Btw thanks a lot bro