Microsoft Interview Question for Software Engineer / Developers






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

Oh..
It will change the order.

- jack daniel March 17, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

MSGEEK, dont know who made you MS Geek. Thats the whole point buddy to push the elements to HashTable.

Think man, think

- Thinker....:) July 08, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char * oddstring(char *s)
{
char *start = s;
char a[256];
for (int i=0;i<256;i++)
a[i] = 0;
while(*s)
a[*s++]++;
s = start;
char *left = start;
while(*s)
{
if (a[*s]%2 == 1)
{
*left++ = *s;
a[*s] = 0;
s++;
}
else
s++;
}
*left = '\0';
return start;
}

- Sum September 06, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if memory is not a constraint, then create an array of size 26 where each index correspond to an alphabet[eg 0 ->a ,1->b..25-> z]. Intialize array with zero.Now iterate thru string and increment the correspondent array index.Now print all the alphabets whose count is odd.

- deagle October 02, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Thinker... has gone nuts. MSGeek was right. Push elements in the HashTable means read each Character of the string and push it into Hashtable keeping its count as Value field. Keep on incrementing count as and when repitition occurs. In the end, scan the Hashtable, do value%2 check and create a string.

As simple as that!

- Pranav February 26, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

use a bitset.. alternate the bit for the char which is found..

go through the bitset when the string ends.. chars which have their bits set to 1 appear odd number of times..

- sid September 13, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think this solution is better then hashtable, particularly considering the space constraints, if stated.

- eace November 15, 2009 | Flag
Comment hidden because of low score. Click to expand.
-1
of 0 vote

{{
//sort the string
void sort(char *c){
int length = strlen(c);
for(int i=1; i<length; i++){
int j = i;
int t = c[j];
while(j>0 && c[j-1]>t){
a[j]=a[j-1];
j--;
}
a[j]=t;
}
}
void deleteOddOccure(char *s){
//check for null
if(*s == '\0')
return;
sort(s);
int length = strlen(s);
char *k = s;
int j=0;
for(int i=0; i<length-1; ){
if( s[i]==s[i+1]){
i=i+2;
}else{
k[j]=a[i];
i++;
j++;
}
}
k[j]='\0';

}
//

}}

- jack daniel March 17, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 0 vote

Simple solution would be to use Hash table.
1)Push all the elements in to the hashtable as keys along with count of their repetitions as values.
2)Now iterate through the elements in the hash table
3)Display only elements where (value%2==1)and these would be the elements with odd number of repetitions.

Lemme know your thoughts.

- MSGeek March 29, 2008 | 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