Given a set of dominoes, write a function which returns true if you can use them all next to each other.
Let me illustrate that:
dominoes=["ab","bc","cd"]
return true, (the way they are given in the array)
dominoes=["ab","cb","cd"]
returns true, (same as above but rotate the 2nd domino)
dominoes=["ab","bc","bd"]
returns false (you can't use the 'b' in "ab" twice to connect "bd" and "bc"
Assume the dominoes are 2 characters from a-z or A-Z
Edit:
dominoes=["ab","ed","bd","aa","bb"]
returns true (pattern aa ab bb bd de)
You can switch the places of the dominoes you don't have to use them in the order given in the array.