Not sure what you mean by unwanted ads.
If you mean ads that appear in apps, then you can usually buy an ad-free version.
If you mean ads that pop up randomly on your screen, that's probably malware. Safest thing is to back up your data and do a factory reset .. then be careful which apps you re-install. Try installing them one or two at a time so if the problem recurs, you know which apps to avoid.