mercredi 24 novembre 2021

checking if linked lists satisfy conditions in if statements in c

So I have a linked list with five "playing cards" and I need to check if any of the two playing cards have the same face. The only way I can think to do this is to brute force it and check each pair individually in a while loop (the first one and the second one, first and third, first and fourth, first and fifth, etc) and if at any time two are the same, break from the loop. But this seems very inefficient, and later I'll have to check if the cards are a full house, royal flush, etc, and this method wouldn't work for those. Is there a more efficient way to check if the nodes in a linked list satisfy certain conditions?

Aucun commentaire:

Enregistrer un commentaire