Cognizant interview question

how would you do this and this.