Microsoft Interview Questions
- 0of 0 votes
Answers#include <iostream>
- anuj.iiit2007 October 02, 2012 in United States
class C {
private:
int num;
public:
C(int a) : num(a) {}
int get_val() const;
};
//changes are not allowed in below code
int C::get_val() const {
num++;
return num;
}
int main() {
C obj(29);
std::cout << obj.get_val() << std::endl;
}
The question was to make the above code work you can make changes only inside class C| Report Duplicate | Flag | PURGE
Microsoft C++ - 0of 0 votes
Answersgiven string is of the form "abcd1234defgh8965" then output should be "a1b2c3d4 d8e9f6g5" with O(n) time??
- rajeshanji8 October 02, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Student student Data Structures - 1of 1 vote
AnswersGiven an array [a1b2c3d4] convert to [abcd1234] with 0(1) space and O(n) time
- kumarasvn October 02, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 0of 0 votes
AnswersGiven two lists sorted in increasing order, create and return a new list representing the intersection of the two lists. The new list should be made with its own memory — the original lists should not be changed.
- soni vashisht September 30, 2012 in United States
For example, let the first linked list be 1->2->3->4->6 and second linked list be 2->4->6->8, then your function should create and return a third list as 2->4->6.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersGiven two numbers represented by two lists, write a function that returns sum list. The sum list is list representation of addition of two input numbers ?
- soni vashisht September 30, 2012 in United States
Example First List: 5->6->3 // represents number 365
Second List: 8->4->2 // represents number 248
Resultant list: 3->1->6 //
Note :Any Carry forward should also be added as the new node . Any Comments on the code below| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 3of 3 votes
AnswersYou have given n numbers from 1 to n. You have to sort numbers with increasing number of set bits.
- pradegup September 29, 2012 in India
for ex: n=5.
output: 1,2,4,3,5
Note: If you have two number with equal number of set bits, then number with lowest value come first in the output.| Report Duplicate | Flag | PURGE
Microsoft Algorithm - 0of 0 votes
AnswersGiven an unsorted array, how to divide them into two equal arrays whose sum of difference is minimum.
- Psycho September 29, 2012 in United States
Can it be done in o(n)?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Morgan Stanley Java Developer Coding - 0of 0 votes
AnswersWrite a program to print the code structure.
- anvijain September 23, 2012 in United States for Windows Azure
(Basically it was to print the nodes of Tree in DFS. )| Report Duplicate | Flag | PURGE
Microsoft Program Manager - 0of 0 votes
AnswersWrite an API to find valid IP address.
- anvijain September 23, 2012 in United States for Windows Azure
(Asked followup questions like which kind or IP format, return type, range specific, etc.)| Report Duplicate | Flag | PURGE
Microsoft Program Manager Coding - 0of 0 votes
AnswersDesign SkyDrive. (open ended question. )
- anvijain September 23, 2012 in United States for Windows Azure| Report Duplicate | Flag | PURGE
Microsoft Program Manager Object Oriented Design - 0of 0 votes
AnswerImplement IEnumerable<string> foo(IEnumerable<string> a, IEnumerable<string> b) such that foo returns string in either a or b but not both
- siva September 23, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C# - 0of 0 votes
AnswersIs this possible?
- Name September 20, 2012 in India for Ad Center
A BST is given. Without using any extra memory AND WITHOUT USING recursion.
1. Convert the BST into Sorted single Linked List.
2. Convert the Sorted Linked List in (1) to exactly identical original BST.
Suppose tree is:
10
/ \
1 N
/ \
N 5
/ \
2 N
/ \
N 4| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersFind the maximum element per level in a BST .?
- kol September 20, 2012 in United States for bing
In O(n) time and O(1) space ..? or O(logn) time and O(n) space.. telephonic interview| Report Duplicate | Flag | PURGE
Microsoft Algorithm - 0of 0 votes
AnswersSwap two nodes in place without using any extra node. For example, if you have lists a->b->c then output should be b->a->-c- and so on..
- M. Sam September 20, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Linked Lists - 0of 0 votes
AnswersMerge Two Arrays A & B where A has enough capacity to hold elements of array B. Also give the number of elements of A & B array. Follow Up- Test this code.
- soni vashisht September 18, 2012 in United States
I need to test if the array is having -ve numbers also. Here is my code :| Report Duplicate | Flag | PURGE
Microsoft Algorithm - 0of 0 votes
Answers/*Find MagickNumber With Duplicate Numbers in Sorted Array 2. Consider a sorted array with all unique numbers. Where a magick number[i] =i */
- soni vashisht September 17, 2012 in United States
/* -10,-5,2,2,2,2,4,7,9,12,13
* */
Why the MAGICK Index be on the left side ?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersNeed to Print all the elements of the ArrayList consisting an ArrayList using C# ?
- soni vashisht September 17, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test C# - 0of 0 votes
AnswersGiven a linked list that contains 0,1 and 2 . Sort this linked such that it contains 0s first, then 1s and then 2s in O(n) time. Remember its a linked list not an array.
- Nascent September 12, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 0of 0 votes
AnswersTo generate armstrong numbers ...In O(n)..
- laterGator September 11, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Student student Math & Computation - 0of 0 votes
Answerswrite a prog O(n) :
- laterGator September 11, 2012 in United States
to interchange million rows to million columns in a file ..| Report Duplicate | Flag | PURGE
Microsoft Student student Algorithm - 2of 2 votes
Answerstwo BST are given find common elements in both....
- abhishek September 09, 2012 in India for idc| Report Duplicate | Flag | PURGE
Microsoft Intern Trees and Graphs - 0of 0 votes
Answersgiven s string "1010101010" in base2 convert it into string with base4.not use extra space....
- abhishek September 09, 2012 in India for idc| Report Duplicate | Flag | PURGE
Microsoft Intern String Manipulation - 0of 0 votes
AnswersDifference in memory allocation for struct & class and class & object.
- arun September 08, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Applications Developer - 0of 0 votes
AnswersJust got out of my interview realizing how ridiculously stupid I answered this question. The question was there is an array of positive and negative integers. Write an algorithm to find the subsequence with largest sum of integers in this array. Also, I can not return the entire array, even if it makes the largest sum. If the largest sum is less than -1, throw an exception.
- sameer.doha September 07, 2012 in United States
I made the mistake of ignoring negative numbers, thinking it would decrease my sum. :(| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays - 2of 2 votes
AnswersGiven an array contains positive and negative values, find the subarray, whose sum is most closed to zero. Require nlogn time complexity.
- wolfyink September 06, 2012 in United States| Report Duplicate | Flag | PURGE
Microsoft Algorithm - 0of 0 votes
Answersgiven linked list a->b->c->d->e convert to
- rockstar September 06, 2012 in India
b->a->d->c->e without creating new node.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven a collection of numbers, print all possible permutations.
- kehkelunga September 05, 2012 in India
Then,told me the code is printing redundant combination.Make change so that one combination is printed only once
1,1,2
[1,1,2], [1,2,1], and [2,1,1].| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGenerate a grey code sequence given the number of digits as input.
- D3^!L September 04, 2012 in India
eg: input=2 output= 00 01 11 10
use minimum space and time complexity| Report Duplicate | Flag | PURGE
Microsoft Data Structures - 0of 0 votes
Answersimplement ur own malloc() function, and free(), in C
- min.bog9 September 03, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Microsoft - 0of 0 votes
AnswersWrite an algorithm to check if a tree is complete binary tree or not.
- kenny September 03, 2012 in India
struct tree {
int info;
struct tree* left;
struct tree* right;
} *root;| Report Duplicate | Flag | PURGE
Microsoft Algorithm