interview-questions

Rectangular region in an array

Given an N*N matrix having 1's an 0's in them and given an integer k,what is the best method to find a rectangular region such that it has k 1's in it ??? ...

How to convert a binary search tree into a doubly linked list?

Given a binary search tree, i need to convert it into a doubly linked list(by traversing in zig zag order) using only pointers to structures in C++ as follows, Given Tree: 1 | +-------+---------+ | | 2 3 | | +----+---+ ...

What is the C-language command for opening a connection with a foreign host over the internet

Could not find a direct answer to this anywhere. Can someone shed some lights. Thanks. ...

Find the minimum element missing from sequence of non-negative integers.

I need to find the minimum missing element from a sequence of non-negative integers. ex: I have: 0 5 10 4 3 1 The missing element is 2. In above sequence missing elements are 2 6 7 8 9 . The minimum among them is 2 so answer is 2. Brute force . I will sort the sequence and get the minimum element in nlogn .I am looking for better so...

find inorder successor in BST without using any extra space.

I am looking a way to find out inorder successor of a node in BST withut using extra space. ...

Are these thread-safe ?

I attended an interview today in which the interviewer asked me the following question : Is re-entrancy and mutual exclusion thread-safe ? Can you explain why ? I am relatively new to concurrent programming and could not answer it.. But i said ... Mutual exclusion is thread safe . But re-entrancy is not and that is the reason why we h...

Finding border of a binary tree

We are given a binary search tree; we need to find out its border. So, if the binary tree is 10 / \ 50 150 / \ / \ 25 75 200 20 / \ / / \ 15 35 120 155 250 It should print out 50 25 15 35 120 155 250 20 150 10. If the binary tree is ...

Maximum interval overlaps using an interval tree

Here is an interesting question: Given a set of N intervals ([start, end]), use an interval tree to find the maximum number of overlapping intervals. A similar question on StackOverflow provided an O(N) solution, but if we can pre-process the intervals into an interval tree, perhaps we can find the solution in logarithmic time. In fact, ...

given a number p , find two elements in array whose product = P.

I am looking for solution for : Given a array and a number P , find two numbers in array whose product equals P. Looking for solution better than O(n*2) . I am okay with using extra space or other datastructure .Any help is appreciated ? ...

Return the result of sum of character arrays

Recently in an interview i was asked a question to write a function which takes two character arrays(integers) as input and returns the output character array. Function Signature: char* find_sum(char* a, char* b) How would one approach this? Example scenario: find_sum("12345","32142") = "44487" Note: The number of digits can be ...

Microsoft interview Question: Find the errors in this function

I was asked this question in the MS written walkin-interview: Find errors in the program below which is supposed to to return a new string with \n appended to it. char* AddnewlinetoString(char *s) { char buffer[1024]; strcpy(buffer,s); buffer[strlen(s)-1] = '\n'; return buffer; } Thank you all. I'd tried to code on myself a...

Give two strings s1 and s2 , give an algorithm to find all characters from S1 which are also in S2.

Example : S1 : abcde S2: cdef Answer : cde ...

Reading AND Writing Access 2 with SSIS

I went for a job interview this morning, and one of the scenarios that the IT manager (a former programmer) told me about was the following .... If anyone could give me any pointers that I can email him pointers to tomorrow (Wednesday 22nd) it may just help tip his decision in my direction. So there's beer in it if you answer a relevent ...

What are some good interview questions for mid-level developers involving ASP.NET MVC?

I have to do some interviewing for mid-level Software Engineer positions and our team uses ASP.NET MVC. Some candidates have experience with the technology and others do not. For the ones that do, we'd like to gauge their expertise. We have come up with some of our own questions, but thought the community might have some good perspective...

Interview Question: Can we have an echo before header ?

I appeared for php test, their I was asked one question for which I could not find the answer. The question is like this. echo "MESSI is injured!!"; header("Location:somepage.php"); Interviewer want both header and echo to be written on the same page. I wonder how's it possible.It should give some error like headers already sent by...

String reversal in C++

I am trying to reverse the order of words in a sentence by maintaining the spaces as below. [this is my test string] ==> [string test my is this] I did in a step by step manner as, [this is my test string] - input string [gnirts tset ym si siht] - reverse the whole string - in-place [string test my is this] - reverse t...

a c program to add two singly linked lists, of unequal lengths containing single digited numbers in all of their nodes

i got this as an interview question. i was given 2 linked lists of unequal lengths,containing a single digited number in each of their nodes. i was asked to build a 3rd linked list which contains the sum of the two linked lists, again in the form of 1 digit in a node. ex: linked list 1 is 4-7-9-6 linked list 2 is 5-7 then the 3rd linked ...

Which of the following is not allowed according to inheritance usage ?

From here, Using inheritance, which of the following is not allowed a) Changing implementation of operation in parent by the subclass b) Using implementation of operation in parent class by the subclass c) Using attributes in parent class by the subclass d) Having operations is subclass which do not exist in parent class e) None A...

Where will the record get inserted first?

I have a schema called "CUSTOMERS". In this schema there is a table called RECEIVABLES. There is another schema called "ACCOUNTS". In this schema, there is a table called RECEIVABLES_AC. RECEIVABLES_AC has a public synoym called RECEIVABLES. The table structure of both the tables is exactly the same. If your front-end uses the custom...

SQL interview question

I got following question on an interview: Given a table of natural numbers with some missing ones, provide output of two tables, beginning of number gap in first table and ending in second. Example: ____ ________ | | | | | | 1 | | 3 | 3 | | 2 | | 6 | 7 | | 4 | | 10| 12| | 5 | |___|___| | 8 | | 9 | | 13 | |___...