Microsoft Interview Question for Software Engineer in Tests






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

Use hashtable to store C1 and C2. Linear time to solve the problem. the downside is that it needs extra memory. Can anybody give an in place O(n) solution?

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

In thi question, C1 and C2 can have different objects at the same time. That means, C1 can have Apples, Oranges, Roses, Coke bottles, Some Integer numbers etc at the same time. Similarly, C2 can have different objects.

The interviewer was asking for test cases if all the objects were Integers. Also, the test cases for mixed collection of objects.

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

I can also think of hashtable only. But extra memory required is not O(n). It is order of types of objects present. So i think it is quite acceptable.

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

good solution

- Anonymous July 31, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

# have an associative array called assocArray[]
# Pass 1: put all the words of set C1 in the assocArray[]
# Pass 2: check if the current word from C2 is there in the array or not
  * at any point if you find a word from C2 not existing in the assocArray, exit()  declaring  that C2 is not a subset of C1
  * if the whole set C2 gets exhausted, declare C2 is a subset of C1.

- LLOLer August 20, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If we kno the complete set of possible objects...den we can have counter for each object/.....
For each element in c1 increment the corresponding counter.....
For each element if c2 decrement the corresponding counter.....
Scan counter,,..
If each element is 0 then c1=c2.
else If all counters are positive or zero....c1 is subset of c2
else If all counters are negative or zero....c1 is subset of c2
else nothing

- Anonymous December 07, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

The gist of the approach is the same. Although I wonder if there's a better solution to this problem.

items1 = set([1, 3, 4])
items2 = set([4, 3, 1])

counts = dict([(item, 1) for item in items1])
for item in items2:
	counts[item] = 3 if item in counts else 2

items1Subset = False; items2Subset = False
for item in counts:
	if counts[item] == 2:
		items1Subset = True
	elif counts[item] == 1:
		items2Subset = True

if items1Subset and items2Subset:
	print "Items1 and Items2 are different" 
elif items1Subset:
	print "Items1 is subset"
elif items2Subset:
	print "Items2 is subset"
else:
	print "Items1 and Items2 are identical"

- Anonymous March 28, 2010 | 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