0
$\begingroup$

I'm looking for a good / efficient algorithm to compare classes of driver licences (or any type of similar objects) and their dates, so that they do not overlap and come in certain order.

eg. We have G1, G2, G, M, etc.

I need to make sure all instances of G1 do not overlap, G1 comes before G2 and does not overlap, and G comes after both, and M is unrelated (there can also be multiple instances of each type, in which case they must not overlap either).

I'm looking to do this without a monster class of if/else statements that no one can ever read.

$\endgroup$
  • $\begingroup$ You write "etc." in your example, but it seems each class needs separate treatment. Is this given by the input or is it simply known beforehand? $\endgroup$ – dkaeae Jul 5 at 7:15
  • $\begingroup$ They are not actually different classes, just a type on the object in this case (string), they are all the same class. $\endgroup$ – Mankind1023 Jul 5 at 18:02
  • 1
    $\begingroup$ Since the huge majority of the worlds population has no idea what these “classes” are, the question is unanswerable. $\endgroup$ – gnasher729 Jul 6 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.