+ 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

12th Jun 2022, 6:33 AM
Kr$na
Kr$na - avatar
4 odpowiedzi
0
Don't pass Hard Code value just take user input.
12th Jun 2022, 7:18 AM
A͢J
A͢J - avatar
0
Bro can you explain a little more
12th Jun 2022, 7:32 AM
Kr$na
Kr$na - avatar
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.
12th Jun 2022, 7:45 AM
A͢J
A͢J - avatar
0
Bro i hadn't reached that level so it is hard to understand for me Btw thanks a lot bro
12th Jun 2022, 7:51 AM
Kr$na
Kr$na - avatar