IBM interview question

two coding questions on hackerrank,