First of all, check iTunes and iCloud to see whether the contacts backed up or not. In default, contacts are backed up automatically when turning on iCloud on your iOS device. However, if you didn't do that, then you need find data recovery app to help you out.