See my code below
Note: originalSize--;
I put this in because when I remove an item I need to stop sooner than otherwise or else I will be out of bound.
It works, but then I noticed others' are working without it. Why do I need it and other don't?
int originalSize = list.size();
for (int i = 0; i < originalSize; i++) {
if (list.get(i).contains("r") && !list.get(i).contains("l")) {
//System.out.println("string contains r but not l: " + list.get(i));
list.remove(i);
i--;
originalSize--;
}
Kent Hervey
Level 19
Why does my verification need an upper bound change on condition?
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
16 November 2019, 04:08
They solved it different than you. If you passed why are you worried? I could write code that solved this task 5 different ways, they are all correct.
0