Skip to content

Instantly share code, notes, and snippets.

@ludflu
Last active May 5, 2016 19:30
Show Gist options
  • Select an option

  • Save ludflu/c49d5442ca0bb0e65d411b8dccde8596 to your computer and use it in GitHub Desktop.

Select an option

Save ludflu/c49d5442ca0bb0e65d411b8dccde8596 to your computer and use it in GitHub Desktop.
We have a large set of medical claims, each of which is assigned an integer that uniquely identifies the claim as
belonging to some otherwise anonymous person. (If multiple claims exist for the same person, they will have the same identifier)
Each claim includes a diagnosis code that indicates what malady they suffer from. Suppose that we pivot these claims to produce a list of files, each named for the diagnosis, which would
contain a list of the integer patient identifiers who's medical claims indicated that they were diagnosed with that
condition.
Now, given that list of files, we want to find the number of people who suffer from BOTH migraines (G43) and gastric ulcers (K25):
G43.txt:
3453234
6367323
8826474
4734737
...
K25.txt:
3453434
4577443
2367733
4574746
...
How should we go about finding the answer to our question? What if these files contain too many patients to fit in memory?
How could we optimize this process for speed? How could we optimize for memory usage?
Please indicate the runtime complexity of your solution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment