Lenovo Ideapad 520S-14IKB regularly loses the second screen capability. An external monitor doesn't display anything, and Windows does not detect the second screen at all. This laptop has two display adapters: Intel HD Graphics 620 and Nvidia GeForce 940MX. The laptop BIOS automatically determines when and for which applications to use the more powerful (and more power-hungry) NVIDIA adapter.
I was able to temporary resolve the issue by uninstalling Nvidia GeForce drivers (via device manager) and rebooting the computer. Unfortunately, this fix didn't last long as Windows would reinstall the NVIDIA driver and after another reboot, the second screen would be gone again.
The proper fix was to update Lenovo BIOS to the latest version (using Lenovo Vintage application). I also installed the latest NVIDIA drivers provided by Lenovo, but the main issue seems to have been the outdated BIOS.
Lenovo Ideapad 520S-14IKB
Windows 10 Home