IBM interview question

Two hackerank questions were asked