interview-questions

Distinguishing extra element from two arrays?

One of my friend was asked this question in an interview - You have given two integer arrays each of size 10. Both contains 9 equal elements (say 1 to 9) Only one element is different. How will you find the different element? What are different approaches you can take? One simple but lengthy approach would be - sort both arrays,...

How to debug a program without a debugger?

Interview question- Often its pretty easier to debug a program once you have trouble with your code.You can put watches,breakpoints and etc.Life is much easier because of debugger. But how to debug a program without a debugger? One possible approach which I know is simply putting print statements in your code wherever you want ...

Linked list interview question

This may be the old, but I couldn't think of an answer. Say, there are two lists of different lengths merge at one point; how do we know where the merging point is? We don't know the length and we should parse each list only once. ...

C# Generics - Strange Interview Question

An interviewer argued me "Genrics are not completely Genrics", He provided the example (Parameters int k,int d are not generic) public static void PrintThis<T>(T a, T b, T c, int k,int d) { } He asked me if i prove still it is generics , i will be allowed to take up the next round. I did not know what he is expecting from me,and wha...

Frequently Asked Riddles in Job Interviews

Were you asked any logic riddles in job interviews? Are you usually asking riddles in job interviews? What are they, and what are the answers? I was asked once how can you divide evenly 5 apples to 6 people without dividing any apple to 1/6 (or 1/12 or 1/18 etc.). (Would love to hear answers in the comments, I'm not sure my answer was ...

Why MVVM and what are it's core benefits?

Why we go for MVVM over MVC or MVP while dealing with WPF? What extra benefit we get by using this? Edit: To be honest , today I had an interview and I have been asked this question. I answered like INotifyPropertyChanged , ICommand,IValue Convertor.. but he was not satisfied. Henceforth I have put up this question Thanks in advance...

Is it true that MyISAM engine is more preferable than InnoDB when we are building clustered storage? Why if it is so?

I heard this today during interview for java developer. I had to list some advantages of MyISAM over InnoDB and why it's still being widely used. And they were waiting to hear from me the answer as the title of this question. As I understand from their own answer: MyISAM doesn't have foreign keys and DB can be easily clustered (one tabl...

Permutations of a given set of numbers

Can someone please explain a good algorithm to find all permutations of a given set of numbers in an efficient manner? ...

Find buy/sell prices in array of stock values to maximize positive difference

Got this question in an interview today, and its optimized solution stopped me cold (which blows, because I really wanted to work for this company...) Given a single array of real values, each of which represents the stock value of a company after an arbitrary period of time, find the best buy price and its corresponding best sell price...

Methods and garbage collection

I encountered this question in an interview: Is an object created inside of a method eligible for garbage collection after the method is finished? Is yes the correct answer? ...

How would I find a book in a large library?

I found the following question while preparing for an interview: You are in a very huge library that has no computer access, and you're looking for one particular book. You look up where the book suppose to be from the card catalog, and went to shelf X to find it. However the book is not there. There is only on...

SQL Question: It's possibile to have a WHERE clause after a HAVING clause?

So... It is possibile to use a WHERE clause after a HAVING clause? The first thing that comes to my mind is sub queries, but I'm not sure. P.S. If the answer is affirmative, could you give some examples? ...

Finding out how a developer handles brownfields projects

I'm doing some job interviews for the first time for my replacement. I want to know how they would approach a brownfields project, but am not really sure how to phrase the question. I'd like to know what their attitude is: e.g. throw out and rewrite, use a tool to refactor, step through the code and understand, what books they've read (...

How do you cope with pressure? When you program??

During programming you might find difficulties on solving some complicated arithmetic code. What is the best way to approach?. ...

What questions should an expert in STL be expected to answer, in an interview

I was looking at a job posting recently and one of the requirements was that a person be a 9/10 in their knowledge of STL. When I judge my skills, to me a 10 is someone that writes advanced books on the subject, such as Jon Skeet (C#), John Resig (JavaScript) or Martin Odersky (Scala). So, a 9/10 is basically a 10, so I am not certain ...

What's the difference between a derived object and a base object in c++?

What's the difference between a derived object and a base object in c++, especially, when there is a virtual function in the class. Does the derived object maintain additional tables to hold the pointers to functions? ...

What are some programming interview questions which give a good indication of one's ability?

What questions do you think are fair to ask in an interview? The position is for an entry level developer, probably right out of college. Hiring managers: What are the fallback questions you typically use and why do you think they are affective? Developers: Are there any questions you have been asked which you really enjoyed while ...

Code Samples for interview

I recently applied for a developer position and the director there asked me to send some samples of code. How should I approach this? Once, I sent a sample of code that I wrote for myself to a company and they didn't get back. This time, I want to be prepared and send appropriate samples. I want to know what I should send them, create ...

What does this C code do [Duff's device]?

void Send(int * to, const int* from, const int count) { int n = (count+7) / 8; switch(count%8) { case 0: do { *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *to++ = *from++; case 3: *to++ = *from++; c...

From an interview: what's the benefit of the stack in C?

I was asked about heap and stack memory structure in an interview. The guy asked me what's the benefit of having the stack? I wasn't sure what he was getting at. What others ways are there to set up address space to execute a c program? ...