OP solved it, closing
This comment is hidden because it contains spoiler information about the solution
In operators: if (a[i] != b[j]) { difference.add(a[i]); You output element a[i] as many times as it does not match the elements b. And it must be equal to 1 time, and then only if it does not coincide with any of the elements b.
When your result looks like the expected one, but still fails, it is helpful to print your string between delimiters and escape whitespace characters.
For your situation:
String s = sb.toString(); System.out.print('"'); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); System.out.print(ch == '\n' ? "\\n" : Character.toString(ch)); } System.out.print('"');
for n = 1, this prints:
n = 1
"*\n \n"
while the expected answer is:
"*\n"
i solved it
test case a = [3, 4, 5] b= [1, 2, 3, 4]
Loading collection data...
OP solved it, closing
This comment is hidden because it contains spoiler information about the solution
In operators:
if (a[i] != b[j]) {
difference.add(a[i]);
You output element a[i] as many times as it does not match the elements b. And it must be equal to 1 time, and then only if it does not coincide with any of the elements b.
When your result looks like the expected one, but still fails, it is helpful to print your string between delimiters and escape whitespace characters.
For your situation:
for
n = 1
, this prints:"*\n \n"
while the expected answer is:
"*\n"
This comment is hidden because it contains spoiler information about the solution
i solved it
test case a = [3, 4, 5] b= [1, 2, 3, 4]
This comment is hidden because it contains spoiler information about the solution