interview-questions

Check my anagram code from a job interview in the past.

Had the following as an interview question a while ago and choked so bad on basic syntax that I failed to advance (once the adrenalin kicks in, coding goes out the window.) Given a list of string, return a list of sets of strings that are anagrams of the input set. i.e. "dog","god", "foo" should return {"dog","god"}. Afterward, I crea...

Reverse a given sentence in java

This was the question asked me in amazon interview. , Write a program to reverse a given sentence like "This is interview question" the output must be "question interview is this".Can any tell me how to get this done? Thanks in advance ...

Acquiring Table Lock in Database - Interview Question

One of my interview Questions, if multiple users across the world are accessing the application, in which it uses a Table which has a Primary Key as Auto Increment Field. The Question how can you prevent the other user getting the Same Primary key when the other user is executing? My answer was I will obtain the Lock on the table and I...

Interview Q: sorting an almost sorted array (elements misplaced by no more than k)

I was asked this interview question recently: You're given an array that is almost sorted, in that each of the N elements may be misplaced by no more than k positions from the correct sorted order. Find a space-and-time efficient algorithm to sort the array. I have an O(N log k) solution as follows. Let's denote arr[0..n) to mean ...

Explain this interview question to me...

Explain this interview question to me... Q: If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b? A: 100, it’s a reference to existing variable. ...

What's the scope of a Javascript variable declared in a for() loop?

Check out the following snippet of HTML/Javascript code: <html> <head> <script type="text/javascript"> var alerts = []; for(var i = 0; i < 3; i++) { alerts.push(function() { document.write(i + ', '); }); } for (var j = 0; j < 3; j++) { (alerts[j])(); } for (var i = 0; i < 3; i++) { (alerts[i])(); } </script> </head><body><...

Programming interview : quick ways to ensure that program is correct

Hi, I faced a telephonic interview recently and I was asked to write a program. The program is non-trivial to understand, but I am asked to write the program. I wrote the program and interviewer showed me bugs on some corner cases. I wish, I could have found the corner cases earlier. what does everyone do in this case. Thanks Bala ...

Compact a given array problem

Dont know whether this is a duplicate, but this was an interview question asked to me. Given an array of random numbers and -1 placed inbetween, I have to compact the array meaning all the -1s are to be replaced and the final output should be the last valid index with the fresh array. For example. Input: 3 4 -1 -1 -1 5 8 -1 8 Output: 3 ...

Interview Q: find angle between hour and minute hands in an analog clock

I was given this interview question recently: Given a 12-hour analog clock, compute in degree the smaller angle between the hour and minute hands. Be as precise as you can. I'm wondering what's the simplest, most readable, most precise algorithm is. Solution in any language is welcome (but do explain it a bit if you think it's nece...

About Interview structure for test automation lab developers

Hi, I am interviewing new applicants for a team that is doing test automation on our company product(s). The team is composed of junior software developers and a team leader. The product runs on windows and has both managed and unmanaged parts. The test automation is done on both client side (user mode and kernel mode) and server side (...

Hello world in C with no semi-colons?

I recently heard this was used as an interview question. I suspect there is a very simple answer; I must be over-thinking it. Can you write Hello World in C without using any semi-colons? If so, how? ...

What is "null pointer assignment error"?

One of job interview questions on C pointers here is the following: what is null pointer assignment error? I've googled for a while and don't see any reasonable explanation. What is that? Trying to write through a null pointer? Something architecture- or environment-specific? What exactly is that error? ...

How does the Eclipse debugger gets the information about private variables inside the class?

this was an interview question posed to me..I vaguely answered it uses Java reflections..but I was not sure. how does that work? ...

A debbugging test, suggestions needed.

I am having a debugging test, as part of an interview.. I thought if any one can help with the approach, when I am faced with a large code base and have to find bugs inside that within an hour or two.This is going to be Core java based app (I guess) on Eclipse 3.2+ ...

Is it possible to apply inheritance to a Singleton class?

Today I faced one question in interview. Is it possible to apply inheritance concept on Singleton Classes? I said since the constructor is private, we cannot extend that Singleton class. Next thing he asked me is to apply inheritance on that Singleton class. So, I made the Singleton's constructor as protected thinking that child's const...

How to find the length of a linked list that is having cycles in it?

This was one of the interview questions asked. How to find the length of a linked list that is having cycle in it. I know how to calculate whether a linked list has a cycle or not using Hare and Tortoise technique. I even know how to calculate the length by storing the addresses in a hashset. The running time of the Algorithm should be O...

linked-list interview question

Hi This was the question asked in interview.Can anybody help me out it in implementing in java Given 2 linked lists(which need not have unique elements) find intersection point in the form of Y.(it can be anywhere--middle or tail) ...

What does "in-place" mean?

Reverse words in a string (words are separated by one or more spaces). Now do it in-place. What does in-place mean? ...

where can I get these kind of exercises to solve?

Recently I did a Java programming exercise successfully which was sent by a recruiting firm, The problem statement goes like this 'There are two text files FI(records abt files and directory information) and FS(containing blocks of data) which represent a file Index and file System respectively and I was supposed to write a static read ...

At What point should you understand References?

I asked a question like this in an interview for a entry level programmer: var instance1 = new MyObject{Value = "hello"} var instance2 = instance1; instance1.Value = "bye"; Console.WriteLine(instance1.Value); Console.WriteLine(instance2.Value); The applicant responded with "hello", "bye" as the output. Some of my co-workers said th...