People with bad quality sleep in their 30s are more likely to suffer from memory problems in later life, new research has discovered.