Interview Question
Software Engineer / Developers#include <iostream>
#include <string>
using namespace std;
int main(){
char str[]="Hello World!";
int len = str.length();
for(int i=0;i<len/2;++i)
swap(&str[i],&str[len-i-1]);
}
void swap(char* a,char* b){
a = a^b;
b = a^b;
a = a^b;
}
1. Take two pointer start and end
- AD February 17, 20102. keep swaping start and end , till start and end do not cross each other.