The quantity and quality of sleep both impact memory!
Explanation: Memories seem to become more stable in the brain during the deep stages of sleep. After that, REM—the most active stage of sleep—seems to play a role in linking together related memories, sometimes in unexpected ways. That's why a full night of sleep may help with problem-solving.
happy to help, have a great day! :)