Frage im Vorstellungsgespräch bei NetApp

How can you reverse words in a string without using extra memory?

Antworten zu Vorstellungsgespräch

Anonym

7. Dez. 2010

include #include using namespace std; void ret_str(char* s) { if(*s != '\0') ret_str(s+1); cout>str; ret_str(str); return 0;

2

Anonym

15. Jan. 2011

The requirements were to reverse the words in the string, not the entire string. So first reverse the entire string in place and then scan and reverse each word in place as you come to it. Reverse the words -> sdorw eht esreveR -> words the Reverse