Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Exercise_19_03 #14

Open
Open
@csv77

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

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp