Interview Question for Software Engineer / Developers






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

1. Take two pointer start and end
2. keep swaping start and end , till start and end do not cross each other.

- AD February 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

forget to mentione
one will need to forward start pointer and backward the end pointer.

- AD February 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include "iostream"
#include "string.h"
using namespace std;

int main(){
char str1[]="Hello World!";
char *p = str1;
char *q = str1 + strlen(str1)-1;
char t;

cout << str1 << endl;

while(p < q){
t = *p;
*p = *q;
*q = t;
p++;
q--;
};

cout << str1 << endl;

}

- Anwar February 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#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;
}

- Rocky February 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

lol swap!

swapping with xor hack won't work when they have identical value(pointer), and you just changed local variable!!(not the contents of pointers)

- Zaphod February 18, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

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

- binary bill February 20, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void reverseString(char *s)
{
int start = 0;
int len = strlen(s);
int end = len-1;
while(start<end)
{
s[start]= s[start]^s[end];
s[end] = s[start]^s[end];
s[start]= s[start]^s[end];
start++;end--;
}
s[len]='\0';
}

- dagnihot March 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

reverse(char *c,int l)
{
char *p,*q;
p=c;
q=c+l-1;
while(*p!=*q)
{
ch=*p;
*p=*q;
*q=ch;
p++;
q--;
}

return;
}

- Anonymous April 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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

- gopi July 30, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#define REVERSE_STRING(X) Rstring(X, *(X), strlen(X)-1)

void Rstring( char *str, char c, int index )
{
if( index != 0 )
Rstring( str, *(str+(strlen(str))-index),index-1);
*(str+index) = c;
}

- Anonymous March 28, 2012 | Flag Reply


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More