IBM interview question

2 LC easy medium questions