Skip to content

Exercise_19_03 #14

Description

@csv77

Hi!
I found a mistake in method removeDuplicates. Inside the for loops there is an if branch. This contains the following:
list.remove(j);
It is wrong, because if you have the same items several times one after another, it will erase only the first one, but not the 2nd, because as you delete the first, the loop will increase value of j, and the 2nd one will not deleted. If you try it with a sample list like this: Chicago, Miami, Chicago, Chicago, Washington, the result will be: Chicago, Miami, Chicago, Washington.
You can correct it, if you decrease 'j' every time you delete an item from the list:
list.remove(j--);
Bye,
Csaba

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions