[Description] Given two integer arrays with the same length. Design an algorithm which can judge whether they're the same. The definition of "same" is that, if these two arrays were in sorted order, the elements in corresponding position should be the same.
[Example]
<1 2 3 4> = <3 1 2 4>
<1 2 3 4> != <3 4 1 1>
[Limitation] The algo...
I have a long string for example it could be "aaaaaabbccc". Need to represent it as "a6b2c3". What's the best way to do this ? I could do this in linear time by comparing characters and incrementing counts and then replacing the counts in the array, using two indexes in one pass. Can you guys think of a better way than this? Are any of t...
I know a few differences,
Value types are stored on the stack where as reference types are stored on the managed heap.
Value type variables directly contain their values where as reference variables holds only a reference to the location of the object that is created on the managed heap.
Is there any other difference i missed... If s...
What kind of topics/questions one can expect in a management round of an interview for a Java/J2EE sr.developer position.
[EDIT] By management round I mean discussion with some one who is playing role of a project manager / technical manager. This round typically takes place after you are through with your coding tests and discussions w...
Original Problem:
I have 3 boxes each containing 200 coins, given that there is only one person who has made calls from all of the three boxes and thus there is one coin in each box which has same fingerprints and rest of all coins have different fingerprints. You have to find the coin which contains same fingerprint from all of the 3 b...
Given the code below, how would you create/implement SR.h so that it produces the correct output WITHOUT any asterisks in your solution?
I got bummed by this question. I would like to know some of the different approaches that people use for this problem.
#include <cstdio>
#include "SR.h"
int main()
{
int j = 5;
int a[] = {10,...
I just got this question on an interview and had no idea how to calculate the answer.
How many additional function calls does fib(n) require if "LINE 3" is removed? The answer should be in terms on n.
int fib(int n) {
if(n == 0) return 0;
if(n == 1) return 1;
if(n == 2) return 1; //LINE 3 HERE <---
return fib(n - 1) + fib(n - 2...
This was one of my interview questions which i couldn't answer.... Is it related to web developement?
What really is a patch?
and my interview question was
how will u start new patch?
...
Different websites are giving different opinions.
My understanding is this:
To clean up or reclaim the memory that an object occupies, the Garbage collector comes into action. (automatically is invoked???)
The garbage collector then dereferences the object. Sometimes, there is no way for the garbage collector to access the object. The...
I came across this question and am looking for some ideas?
...
Here one more basic question asked in MS interview recently
class A {
public virtual void Method1(){}
public void Method2() {
Method1();
}
}
class B:A {
public override void Method1() { }
}
class main {
A obk = new B();
obk.Method2();
}
So which function gets called? Sorry for the typos.
...
How to find the integer occurring maximum number of times (mode) in an unsorted array of integers?
One O(nlogn) approach I could think of is to sort. Is there any other better approach?
...
I was recently given this interview question and I'm curious what a good solution to it would be.
Say I'm given a 2d array where all the
numbers in the array are in increasing
order from left to right and top to
bottom.
What is the best way to search and
determine if a target number is in the
array?
Now, my first inc...
I have recently come across an interesting question on strings. Suppose you are given following:
Input string1: "this is a test string"
Input string2: "tist"
Output string: "t stri"
So, given above, how can I approach towards finding smallest substring of string1 that contains all the characters from string 2?
...
This is an interview question I faced recently.
Given an array of 1 and 0, find a way to partition the bits in place so that 0's are grouped together, and 1's are grouped together. It does not matter whether 1's are ahead of 0's or 0's are ahead of 1's.
An example input is 101010101, and output is either 111110000 or 000011111.
Solv...
I recently encountered with this question: How to reduce this expression: s>73?61:60;.
The hint given was that Instead of using conditional operator we could use a simple comparison which will work fine.
I am not sure but I think it is possible with some GCC extension,although I am unable to figure it out myself.
EDIT:The whole expre...
I found this open question online. How do you process a large data file with size such as 10G?
This should be an interview question. Is there a systematic way to answer this type of question?
...
I w'd really appreciate if somebody suggest me any book which has good interview questions on C++, STL and boost?
...
Given an array. How can we find sum of elements in index interval (i, j) in constant time. You are allowed to use extra space.
Example:
A: 3 2 4 7 1 -2 8 0 -4 2 1 5 6 -1
length = 14
int getsum(int* arr, int i, int j, int len);
// suppose int array "arr" is initialized here
int sum = getsum(arr, 2, 5, 14);
sum should be 1...
Yesterday i had a question in an interview which i thought i could find answers here in SO...
How to find 3rd max value of a column using MAX function in sql server?
Consider the column to be
Wages
20000
15000 10000 45000 50000
...