## Amazon Interview Question for Software Engineer / Developers

Comment hidden because of low score. Click to expand.
1
of 1 vote

we can do it in single scan.just scan each and every letter of the string and push it in the stack.Now pop the elements from the stack

Comment hidden because of low score. Click to expand.
0
of 0 vote

Func Def
void iter_RevString( cha* str, int len)
{
for(int i=0; i<len/2; i++)
{
str[i] ^= str[len-1-i];
str[len-1-i] ^= str[i];
str[i] ^= str[len-1-i];
}
}

Func call -
iter_RevString(string, strlen(string));

Comment hidden because of low score. Click to expand.
0
of 0 vote

void StrRev(char *str)
{
char temp;

for (int i = 0; i < strlen(str)/2; i++) {
temp = str[len-1-i];
str[i] = str[len-1-i];
str[len-1-i] = temp;
}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````def strreverse():
mystr = ['c', 'o', 'd', 'i', 'n', 'g', ' ', 'i', 's', ' ', 'f', 'u', 'n']

for i in range(0, len(mystr)):
j = (len(mystr)-i) - 1
if i == j or i > j:
break
e = mystr[j]
mystr[j] = mystr[i]
mystr[i] = e

print mystr``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

func(char * arr, int size){
int i = 0;j=size-1;
while(j>i){
swap(a[i++],a[j--]);
}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

unc(char * arr, int size){
int i = 0;j=size-1;
while(j>i){
swap(a[i++],a[j--]);
}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

use recursive if allowed to use.. it will reduce the speed but has its own disadvantages

Comment hidden because of low score. Click to expand.
0
of 0 vote

This technique might be optimal for your question:

``````void strrev(char *str)
{
if(str[0] == NULL)
return;
else
{
strrev(str+1);
printf("%c",str[0]);
return;
}
}``````

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.