employer cover photo
employer logo
employer logo

Carnegie Technologies

Questa è la tua azienda?

Domanda di colloquio di Carnegie Technologies

How do you write a C code to reverse a string array i.e write code to convert the input string array "HELLO" to "OLLEH" without duplicating the string.

Risposta di colloquio

Anonimo

29 gen 2019

You could have a pointer at the start of array and end of array. Then just swap values, increment start index and decrement end index. Loop until start index and end index are equal. Time complexity of O(n) and space complexity is constant/O(1)