IBM interview question

2 DSA questions through hackerrank.