I think I installed a virus to my galaxy s7 edge I dont know what could have given my phone a virus.

I get random adds on my phone when i am not even on an app, no apps were opened and my phone was locked and i pressed the home button to see the time and an add started playing on the screen. 


Is there any way to get rid of it without having to Factory reset my phone?

S