IBM Interview Question

Two hackerank questions were asked