Microsoft Interview Question for Applications Developers


Country: India
Interview Type: Written Test




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

Another approach is to change from base 10 to larger base like base 67.

- Anonymous November 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
3
of 3 vote

Each integer has 32 bits. So, it can accommodate at-least 9 digits.
The idea is club as many numbers as possible to a single number. While clubbing we have to maintain the number of digits of each number being clubbed. Hence, if input number is 'xyz', then in output we have to write 4xyz. While decoding, use these extra digits as delimiters.
Example:
If we have [1,2,3,4,5,20,123], we can convert into [11121314,152203123] .
Initial memory required=7*4=28 bytes
After compression, memory required=2*4=8 bytes.

- Anonymous November 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

provide the program in c++ please.

- Anonymous October 15, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

provide program in c++ please..

- raju October 15, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

provide the program in c++ please..

- Arulmozhi October 15, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

{ provide program in c++}

- Arulmozhi October 15, 2015 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 vote

I dont think MS wants to test our Data Compression Skill set. I would go for Run Length Encoding which is the simplest.

- Arulmozhi November 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This can be used only for single digits, I think. There will be no delimiter to decode the so formed string.

- alex October 12, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

This is my approach
1. Create a int array of size 10 +1 for separator.
2. Loop through each integer and update its frequency for [111,1923] => 0,4,1,1,0,0,0,0,0,1,1
3. Construct Huffman tree with these most frequently occurred near root.
4. Compress the data and return byte[].
5. Do the inverse in uncompress take byte[] and return int[].

- Anonymous November 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

How do you implement the inverse of the encoding ?

- venkatasagar November 19, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

difference queue

- G November 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It will be appreciated If you can provide me the solution in java

- manish.89july November 15, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Write two functions:

First function takes in an array and returns the compressed data in any format.
Second function takes in the compressed data and returns the array in original format.

- manish.89july November 15, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think he's right since in the question, if observed carefully they have mentioned " array with sequence of numbers"

- agmegharaj November 29, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Are there any examples?

- nixfish November 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

i consider most of these answers as over engineering. Almost all of them have missed the fact that the given list is a "sequence". All you need to do is write the first digit of each sequence and the actual sequence length and keep repeating.
For e.g. 1, 2, 3 7, 8, 13, 17, 18, 19, 20 becomes 1,3,7,2,13,1,17,5

- Raghu November 29, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I meant.. 1,3,7,2,13,1,17,4.

But you get the point. Larger the sequence, better is the result.

- Raghu November 29, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think you're misinterpreting the usage of the word "sequence" here. I doubt that the term "sequence" in the problem statement was meant to mean anything special. I think the question is just "Given an array of integers, how would you compress that?"

- eugene.yarovoi November 30, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I don't know if I misunderstood. Check the other questions from the same person who asked this. (check the id=14990674). I think by sequence, he means consec numbers. May be I am wrong.

- Anonymous December 01, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think Raghu is 100% correct, this questions looks to be a follow up questions. And yes, person must clarify this with interviewer as to what he meant by sequence

- Areeb December 08, 2012 | 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