Microsoft Interview Questions
- 2of 2 votes
AnswersPoint errors (if any) in the following pointer code and explain what it does...
- Jeanclaude March 17, 2015 in United States
char* cp(char *a)
{
char *f;
f=(char*)malloc(strlen(a)*sizeof(char));
while(*a != 0)
{
*f=*a;
f++;
a++;
}
cout<< f;
return f;
}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test C++ - 2of 2 votes
Answersgiven a string determine which character appears the most and the number of times that character appeared.
- Glenwright327 April 25, 2014 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersImplement a class that does string manipulation by overloading the following operators: <<, >>, = and ==. For example consider the following code:
- Pritam March 05, 2014 in United States
StrShift example;
example = “Microsoft”;
printf(“\”example << 2\” results in %s\n“, example << 2);
In the above code the output would be “ftMicroso” which shows the last two characters of the string “Microsoft” rotated to the left of the string. Please note that state is maintained so two calls of example << 1 would give the same end result as calling example << 2 once.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 3of 3 votes
Answers3. Write a class that represents a minimal heap. The heap class should at a minimum support the following methods:
- Pritam March 04, 2014 in United States
- AllocTinyHeap() which should initialize the heap with a given amount of bytes
- DeleteTinyHeap() which frees all memory associated with the heap
- TinyAlloc() which allocates a given number of bytes on the heap if there is room
- TinyFree() which frees a specific location on the heap
You may define whatever parameters are necessary for the above methods as well as write any additional methods. Overall consideration will be given to correctness, design, code readability as well as any unit testing done. As part of a final solution please submit test cases you used to verify correctness in addition to any unit tests done.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersForgot to add this question along with my previous...
- Jeanclaude January 27, 2014 in United States
This is a brain teaser type question...
S E N D
+
M O R E
--------------
M O N E Y
--------------
Each of the above characters hold a specific value which is unique (meaning no two characters have same value). Now the question is, to uncover what value each character stands for...
(Hint - 'M' has to be 1 because it's the carry in the result (M O N E Y). Now similarly back track the rest of the characters)
Note: this hint is given by me, for the sake of understanding the question for interested folks, it was not given to me in the interview).| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 0 votes
AnswersImagine we have a large string like this "ABCBAHELLOHOWRACECARAREYOUIAMAIDOINGGOOD" which contains multiple palindromes within it, like ABCBA, RACECAR, ARA, IAMAI etc... Now write a method which will accept this large string and return the largest palindrome from this string. If there are two palindromes which are of same size, it would be sufficient to just return any one of them.
- Jeanclaude January 22, 2014 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test String Manipulation - 0of 0 votes
AnswersGiven two strings remove duplicates and test it
- AVK November 08, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 0 votes
AnswersGiven a function to reverse a linked list write code to test the function
- AVK November 08, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 1of 1 vote
AnswersRemove common characters from two strings and print the common characters and test cases
- AVK November 08, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 1of 1 vote
AnswersDelete m nodes for every n nodes in linked list and write the test cases
- AVK November 08, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - -8of 8 votes
AnswersGiven a result in string of pass, fail, blocked, unknown as pppppppfffffbbbbbuuuuu or pppppppppppppppfffffff or pfpfpfpfpfpfpfpfpuuuuuuuuu or any combination of characters from p,f,b, or unknown character say u or x or y or z... question is write a program which can identity a pattern like all tests passed or all tests are failing or tests started failing (blocking issue may be) or unknown pattern... this is what my friend recall if someone also faced this question and recall better explaination , please add.. interviewer asked to code the solution not algo...
- Jack Williams November 01, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Coding - 0of 0 votes
AnswersGiven array of words, group the anagrams
- abhinav27rulez July 29, 2013 in United States
IP:{tar,rat,banana,atr}
OP:{[tar,rat,atr],[banana]}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 2of 2 votes
AnswersThe object of this exercise is to fix 3 known issue with the existing code, and add a new feature to the tool.
- Purushotham Kumar July 05, 2013 in Ireland for CPL Recruitment Team @Microsoft
The known issues to address are:
· The current implementation of the tool incorrectly ignores white space (spaces and tabs) between words, which is a bug. Modify the code so that white space differences are correctly detected
· Tool doesn't report difference if second file is larger than first file
· For large input files the tool consumes considerable RAM. Modify tool to address this performance bug
The new feature to implement is:
· Add a new command line switch -i and functionality to allow case-insensitive comparison
Running the tool requires you to supply 2 command line arguments – these will be the paths to 2 text files that should be compared. You are responsible for creating this test data.
/*
* New Requirement:
* - Add a new command line switch -i and functionality to allow case-insensitive comparison.
*
* Issues to fix:
* - The current implementation of the tool incorrectly ignores white space (spaces and tabs) between words, which is a bug.
* Modify the code so that all white space differences are correctly detected and reported along with differences in words.
* - Tool doesn't report difference if second file is larger than first file.
* - For large input files the tool consumes considerable RAM. Modify tool to address this performance bug.
*
* Please ensure you include all test files that you create for each of your test cases along with your submission.
*/
namespace CsDiff
{
using System;
using System.Collections.Generic;
using System.IO;
class Program
{
static void Main(string[] args)
{
if (!ProcessArgs(args))
{
return;
}
using (FileReader sourceFile = new FileReader(args[0]))
using (FileReader targetFile = new FileReader(args[1]))
{
IEnumerator<string> sourceEnum = sourceFile.Words.GetEnumerator();
IEnumerator<string> targetEnum = targetFile.Words.GetEnumerator();
for (int word = 1; sourceEnum.MoveNext() && targetEnum.MoveNext(); word++)
{
if (sourceEnum.Current != targetEnum.Current)
{
Console.WriteLine("Difference at position {0}: '{1}' different to '{2}'",word,sourceEnum.Current, targetEnum.Current);
}
}
}
}
static bool ProcessArgs(string[] args)
{
if (args.Length != 2)
{
Console.WriteLine("Please specify [source] and [target] file paths");
return false;
}
for (int arg = 0; arg <= 1; arg++)
{
if (String.IsNullOrEmpty(args[arg]) || !File.Exists(args[arg]))
{
Console.WriteLine("File '{0}' not found", args[arg]);
return false;
}
}
return true;
}
}
public class FileReader : IDisposable
{
string[] words;
public FileReader(string path)
{
string fileData = File.ReadAllText(path);
words = fileData.Split(new char[] { ' ', '\t' });
}
public IEnumerable<string> Words
{
get
{
return this.words;
}
}
public void Dispose()
{
}
}
}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 1of 1 vote
AnswersGiven an mxn matrix, design a function that will print out the contents of the matrix in spiral format.
Spiral format means for a 5x5 matrix given below:[ 1 2 3 4 5 ] [ 6 7 8 9 0 ] [ 1 2 3 4 5 ] [ 6 7 8 9 0 ] [ 1 2 3 4 5 ] path taken is: [ > > > > > ] [ > > > > v ] [ ^ ^ > v v ] [ ^ ^ < < v ] [ < < < < < ] where ">" is going right, "v" going down, "<" is going left, "^" is going up.
The output is:
- masrur.macece June 26, 2013 in United States for Windows Hyper-V1 2 3 4 5 0 5 0 5 4 3 2 1 6 1 6 7 8 9 4 9 8 7 2 3
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersOpen two instances of Microsoft Word and print to printer simultaneously. How would the underlying printer driver work? How would you design the printer driver?
- masrur.macece June 26, 2013 in United States for Windows Hyper-V| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Computer Architecture & Low Level - 0of 0 votes
AnswersDesign an algorithm to find all the nouns and verbs present in a book. Discuss and explain your decision as to why you chose that algorithm.
- Jeanclaude June 21, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 0 votes
AnswersPrint the actual phone number when given an alphanumeric phone number. For e.g. an input of 1-800-COM-CAST should give output as 18002662278 (note: output also does not contain any special characters like "-").
- Jeanclaude June 16, 2013 in United States for Windows Phone| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Hash Table - 13of 19 votes
AnswersWrite a program to find whether a given number is a perfect square or not. You can only use addition and subtraction operation to find a solution with min. complexity.
- Purushotham Kumar June 12, 2013 in Ireland
i/p : 25
o/p : True
i/p : 44
o/p: False| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 0 votes
AnswersWrite a program to reverse a sentence in a zigzag order.
- Purushotham Kumar June 09, 2013 in Ireland
i/p: I am a software programmer
o/p: programmer erawtfos a ma I| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 1of 1 vote
AnswersFind the first non repeating character in a given string. You may assume that the string contains any character from any language in the world, for e.g. an Arabic
- Jeanclaude June 09, 2013 in United States for Windows Phone
or Greek character even.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test String Manipulation - -1of 3 votes
Answerswrite a sample code to find no of 'a' words in a sentence?
- raghuram2404 June 07, 2013 in India
Eg: If a sentence is given as "I found an apple in a tree."
The output is : 1 (not 2)
We have to count no of words.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 5of 5 votes
AnswersIf a linkedlist is having loop, how to find the last node of the loop .
- zammer May 28, 2013 in India for SDET| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - -4of 4 votes
AnswersA large character array is there in which there are spaces in between the character like ab c d ...etc
- zammer May 28, 2013 in India for SDET
Write a method to search any character in the above array in O(n).| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 1of 1 vote
AnswersCode to check if a given short string is a substring of a main string. Can you get a linear solution (O(n)) if possible?
- Jeanclaude May 18, 2013 in United States for Office| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test String Manipulation - 0of 0 votes
AnswersWrite a program to calculate Sum of two singly linked lists.
- shaktiman April 30, 2013 in -
e.g.
1-->2-->3
8->9->10
.
Result list should be 10-->2-->3
You are not allowed to make any change in input lists. Those are read only.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - -2of 4 votes
Answersfind a pattern in byte array and change that pattern in place (do not use temp array or variable)
for example, find pattern 0,0,3 in an byte array and replace it with 0,0
should be o(n)
my solutions :
- SDguy April 03, 2013 in United StatesByte*remPattern003(byte arr[] , int &size) //size is input and output variable ///outputs size of output array { int k = 0; for(int i=0;i<size;) { if(arr[i] == 0 && arr[i+1] == 0 && arr[i+2] == 3) { arr[k++]=arr[i]; arr[k++]=arr[i+1]; arr[k]=arr[i+3]; i+=3; } else arr[k++]=arr[i++]; } size= k; return arr; }
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Arrays - 0of 0 votes
AnswersHow to check if a binary tree is a binary search tree?
- SkyClouds March 26, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersWrite a program in C to read all the characters from standard input and output the reverse when the user presses enter key.
- Expressions March 19, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersWrite a program in C to do run length encoding of an string in place. Desired space complexity O(1).
- Expressions March 19, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm