Two different apple id 's contacts sync together
You mentioned, "I have sign out my apple id and deleted my contacts then...", if you are sure about that, you don't have to worry about your friend getting your contacts. 

After your friend signing in their Apple ID on your phone, you or your friend probably might not select to delete the contacts after signing out from your device. That would be the reason that you can see your friend's contact. 

You can easily restore your contacts via iCloud (https://www.icloud.com/#settings).