Question d’entretien chez J.P. Morgan

Two coding questions first easy and second medium?