comparing the contents of two huge text files quickly

前端 未结 3 1710
走了就别回头了
走了就别回头了 2021-02-03 16:44

what i\'m basically trying to do is compare two HUGE text files and if they match write out a string, i have this written but it\'s extremely slow. I was hoping you guys might

3条回答
  •  猫巷女王i
    2021-02-03 17:14

    You have a cartesian product, so it makes sense to index one side instead of doing an enhaustive linear search.

    Extract the keys from one file and use either a Set or SortedList data structure to hold them. This will make the lookups much much faster. (Your overall algorithm will be O(N lg N) instead of O(N**2) )

提交回复
热议问题