79348000

Date: 2025-01-11 11:50:36
Score: 0.5
Natty:
Report link

Firstly these can be better stored, when you come to search these lists for the value it will currently be O(n). The data can be better stored in the form of a Bag (a set which is a set that allows duplicates) of patterns, or a dictionary where the keys are the patterns. These are likely to be implemented with a binary tree or a hash table, leading to O(log n) or O(1) searches.

You will need to iterate over the patterns stored in both bags, a language agnostic way to achieve this would be to form a set (so you don't get duplicates) of all the patterns in both bags. However with many languages you may manage to avoid storing a new set by writing a custom iterator or generator with knowlege of both bags.

When it comes to interpret the results of the comparison, this will vary by how detailed an output you want, do you just want to know if there is any difference, or a count of total differences, or to know which patterns differ, or the total differences by pattern, and do you need to know which list has more/less of each pattern?

Assuming you just want the total differences the algorithm would be to:

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Neil Butcher