interview-questions

Find largest rectangle containing only zeros in an N×N binary matrix

Given an NxN binary matrix (containing only 0's or 1's), how can we go about finding largest rectangle containing all 0's? Example: I 0 0 0 0 1 0 0 0 1 0 0 1 II->0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 <--IV 0 0 1 0 0 0 IV is a 66 binary matrix; the return value in this case will be Cell 1: (2, 1) a...

What's the fastest way to brush up on algorithms for a technical interview (on Monday)?

I have a technical interview on Monday and they were kind enough to give me a heads-up to brush up on my basic algorithms. It's been years since I looked at that kind of stuff and I'm pretty weak on it to begin with so I generally have a bad feeling about this. What's the best way to review the basics and get some practice in before Mond...

Millions of 3D points: How to find the 10 of them closest to a given point?

A point in 3-d is defined by (x,y,z). Distance d between any two points (X,Y,Z) and (x,y,z) is d= Sqrt[(X-x)^2 + (Y-y)^2 + (Z-z)^2]. Now there are a million entries in a file, each entry is some point in space, in no specific order. Given any point (a,b,c) find the nearest 10 points to it. How would you store the million points and how w...

Pro JavaScript programmer interview questions (with answers)

What are good questions to determine if applicant is really a pro JavaScript (browser side) developer ? Questions that can distinguish if someone is not an ad-hoc JavaScript programmer, but is really doing professional JavaScript development, object-oriented, reusable, and maintainable. Please provide answers, so an intermediate and ad...

Given an array of integers where some numbers repeat 1 time, some numbers repeat 2 times and only one number repeats 3 times, how do you find the number that repeat 3 times.

Given an array of integers where some numbers repeat 1 time, some numbers repeat 2 times and only one number repeats 3 times, how do you find the number that repeat 3 times. Using hash was not allowed. Complexity of algorithm should be O(n) ...

Which loop configuration will take more time to run?

Code I: for(i=0; i<100; i++){ for(j=0; j<1000; j++){ x = y; } } Code II: for(i=0; i<1000; i++){ for(j=0; j<100; j++){ x = y; } } Can you explain why one of these loop configurations will take more time to run than the other? ...

MATLAB interview questions?

I programmed in MATLAB for many years, but switched to using R exclusively in the past few years so I'm a little out of practice. I'm interviewing a candidate today who describes himself as a MATLAB expert. What MATLAB interview questions should I ask? Some other sites with resources for this: "Matlab interview questions" on Wilmo...

Number of different elements in an array.

Is it possible to compute the number of different elements in an array in linear time and constant space? Let us say it's an array of long integers, and you can not allocate an array of length sizeof(long). P.S. Not homework, just curious. I've got a book that sort of implies that it is possible. ...

LRU cache design

Least Recently Used (LRU) Cache is to discard the least recently used items first How do you design and implement such a cache class? The design requirements are as follows: 1) find the item as fast as we can 2) Once a cache misses and a cache is full, we need to replace the least recently used item as fast as possible. How to analyze a...

What is a typical algorithm for finding a string within a string?

I recently had an interview question that went something like this: Given a large string (haystack), find a substring (needle)? I was a little stumped to come up with a decent solution. What is the best way to approach this that doesn't have a poor time complexity? ...

How to find validity of a string of parentheses, curly brackets and square brackets?

I recently came in contact with this interesting problem. You are given a string containing just the characters '(', ')', '{', '}', '[' and ']', for example, "[{()}]", you need to write a function which will check validity of such an input string, function may be like this: bool isValid(char* s); these brackets have to close in the co...

Will the following program cause any problem during compiling and execution process?

Will the following program cause any problem during compiling and execution process? class A{ public: virtual void foo(){} }; class B:public A{}; int main(){ B b; b.foo(); } ...

need thoughts on my interview question - .net, c#

One of the questions I was asked was that I have a database table with following columns pid - unique identifier orderid - varchar(20) documentid - int documentpath - varchar(250) currentLocation - varchar(250) newlocation - varchar(250) status - varchar(15) I have to write a c# app to move the files from currentlocation to newlocati...

How to arrange an array in decreasing order of frequency of each number?

Input : {5, 13, 6, 5, 13, 7, 8, 6, 5} Output : {5, 5, 5, 13, 13, 6, 6, 7, 8} The question is to arrange the numbers in the array in decreasing order of their frequency, preserving the order of their occurrence. If there is a tie, like in this example between 13 and 6, then the number occurring first in the input array would come first...

Can a pointer ever point to itself?

This question was mentioned here. My question is: If a pointer variable has the same address as its value, is it really pointing to itself? For example - in the following piece of code, is a a pointer to itself? #include<stdio.h> int main(){ int* a; int b = (int)&a; a = b; printf("address of a = %d\n", &a); printf(" ...

Interview Questions that can be asked on TCP/IP, UDP, Socket Programming ?

I am going for an interview day after tomorrow where i will be asked vaious questions related to TCP/IP and UDP. As of now i have prepared theoritical knowledge about it. But now I am looking up for gaining some practicle knowledge related to how it works in a network. What all is going in vaious .NET classes. I want to create a very sm...

What will happen when I call a member function on a NULL object pointer?

I was given the following as an interview question: class A { public: void fun() { std::cout << "fun" << std::endl; } }; A* a = NULL; a->fun(); What will happen when this code is executed, and why? See also: When does invoking a member function on a null instance result in undefined behavior? ...

Must have JavaScript pro developer tools, libs, utilities and workshop configuration.

This is a followup question to the Pro JavaScript programmer interview questions (with answers). What is considered professional and industrial standard for a professional browser side Java Script developer when it comes to his workshop configuration, and maybe from-concept-to-shipment process? What are the most popular IDE's, utiliti...

Retrieving the top 100 numbers from one hundred million of numbers

One of my friend been asked with a question, Retrieving the max top 100 numbers from one hundred million of numbers, in a recent job interview. Do you have any idea to come up with an efficient way to solve it? regards! ...

Interview question: Check if one string is a rotation of other string.

A friend of mine was asked the following question today at interview for the position of software developer: Given two string s1 and s2 how will you check if s1 is a rotated version of s2 ? Example: If s1 = "stackoverflow" then the following are some of its rotated versions: "tackoverflows" "ackoverflowst" "overflowstack" where as...