IBM Interview Question

two coding questions on hackerrank,