Microsoft Interview Question for Software Engineer / Developers






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

Altaf, I am just curious how you answered this question. I think you did pretty well on the interview. Were there any other questions that you think you might have done bad on?

- Neo May 04, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I defined test cases like
- Passing first string as null string
- passing second string as null string
- passing both strings as null string
- passing two different strings (non anagrams)
- passing two anagram strings, one with upper case
- passing two anagram strings containing integers
- passing two strings composed of whitespace only
- passing two correct anagram strings
- passing two correct anagram non english strings

Actually I had 25 minutes interview only, I dont know why. But before starting interview, the interviewer told me that we will be having 25 minutes interview. Before it was scheduled for 45 minutes. So these were the only 3 to 4 questions which were asked to me in interview :(

- Altaf Al-Amin Najwani May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

strings with double letters add, ad
strings with one letter few times: ddd,dd
string with 1 letter f,g

Question:
Are dd, d are anagram?
Does anagram restricted to letter or any ascii char?

- Eila June 12, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Could you please tell me what is meant by anagram? Does it mean: Str1 and Str2 should contain same set of characters??

- Sadineni August 14, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

More test cases:
* special characters
* numbers?

@Elia- d and dd are not anagrams.

- Sunil August 17, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Test cases:
1. Test with known anagrams e.g. "care" and "race"
2. Test with know non-anagrams
3. Test above cases with different cases - upper case and lower case
4. Test with non dictionary words
5. Test with super long strings
6. Test with null strings
7. Test with one valid and another null string
8. Test with one char strings
9. Test with strings containing a space in between
10. Test with hyphenated words
11. Repeatedly call the function 1000 times
12. Call the method in a a multi threaded environment
13. Test with unicode
14. Test with foreign language words
15. Test with alpha-numeric strings

- Sesh February 25, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

very detailed answer, thanks for sharing

- Gaurav Khurana September 07, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

16. Test memory leaks when the function is working
17. Time the functions for different lengths of words

- Sesh February 25, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Code for checking if two strings are anagrams...

#include<stdio.h>
#include<stdlib.h>
void main()
{
char str1[1000], str2[1000], len1 = 0, len2 =0, a[256];
int flag = true;
printf("Enter the first string\n");
gets(str1);
printf("Enter the second striing\n");
gets(str2);

for(int i =0;i<256;i++)
a[i] = 0;

while(str1[len1] != '\0')
{
a[str1[len1]] = a[str1[len1]] + 1;
len1++;
}

while(str2[len2] != '\0')
{
a[str2[len2]] = a[str2[len2]] - 1;
len2++;
}
if((len1 != len2) || str1 == 0 || str2 == 0)
{
printf("Not an Anagram\n");
exit(0);
}

for(int i =0;i<256;i++)
if(a[i] != 0)
{
printf("Not an Anagram\n");
flag = false;
break;
}
if(flag)
printf("The two strings form an Anagram\n");
}

- gauravk.18 February 17, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Why condition "str1 == 0 || str2 == 0" is required ?
MoreOver above program gives two null strings also anagram.

- Amit March 26, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

str1 and str2 == 0 means if both the strings are NULL. In that case the program will output...Not Anagrams...

- gauravk.18 April 17, 2008 | Flag


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