Deleting duplicate lines in a file using Java

后端 未结 14 565
予麋鹿
予麋鹿 2020-12-14 01:39

As part of a project I\'m working on, I\'d like to clean up a file I generate of duplicate line entries. These duplicates often won\'t occur near each other, however. I came

14条回答
  •  一生所求
    2020-12-14 02:19

    • Read in the file, storing the line number and the line: O(n)
    • Sort it into alphabetical order: O(n log n)
    • Remove duplicates: O(n)
    • Sort it into its original line number order: O(n log n)

提交回复
热议问题