Implemented the function areDifferentColors