First of all, save any important files that you have, such as photos, documents, spreadsheets, and so on, to a USB stick. Keep this USB safe as you fix your computer.
Then, to get rid of the hacker, you would be advised to do a clean install of your operating system, whether that is Windows, MacOS, and so on. You can find this by going into 'advanced recovery mode'.
This will wipe the hard drive and then install a new version of your OS. You can then restore your important files using the USB stick. I hope this helped you.