Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
OP solved it, closing
Yes, this was the first solution. I didn't like it either. Then I corrected it to the flag. Thanks for the detailed comment! ๐
The "a[i] = 99999999;" line is avoidable by using a flag like "boolean present = true"
but even then, the loop keeps going until the end.
Is fixable by doing something like "if ((a[i] == b[j]) && !present)" but it is so unreadable.
The best way, I think, is to just put the inner loop into a new function isPresent() which takes a[i] and b as parameters, instead of "a[i] = 9999999" the function would return true, and would return false instead if the loop ends.
This comment is hidden because it contains spoiler information about the solution