Cyware interview question

Solve given DSA questions with constant space constraint