Topic — Add New » Posts Last Poster Freshness
Google interview question 1 gautam5669 7 hours

Given two BST print the element in sorted form

complexity O(n) time maxm alloted space will be O(height of bigger tree)

eg ;

T1
     3
1       5

T2

    4
2       6

o/p 1 2 3 4 5 6

puzzle 1 sresta 10 hours

write a program in which printf print -1 ......when printf executes sucessfully den it returns positive value.....same as.. if printf doesn't execute successfullyden it prints -1 ..when?

Longest Increasing Subsequence O(nlogn) 2 Venki 15 hours

Can someone please explain O(nlogn) algo for LIS or give some good link other than the one at wiki and algorithmist??
Thanks!!

Microsoft Interview Question for Software Engineer/Developer about Algorithms, Arrays 2 Venki 15 hours

Give an O(n log n)-time algorithm to find the longest monotonically increasing subsequence of a sequence of n numbers((Hint: Observe that the last element of a candidate subsequence of length i is at least as large as the last element of a candidate subsequence of length i - 1. Maintain candidate subsequences by linking them through the input sequence)

Microsoft
Getting kth smallest element 1 Guddu Sharma 22 hours

Find the kth smallest element in an unsorted array.
My approach is the modified partitioning algorithm done during quick sort.
Here is the code which is working correctly. Please help me out getting the time complexity of the code..

int partition(int *arr,int low,int high)
{
	int pivot,i,j;
	i=low;
	j=high+1;
	pivot=arr[low];

	while(1)
	{
		do
			i++;
		while(i<=high && pivot>arr[i]);

		do
			j--;
		while(j>low && pivot<arr[j]);

		if(i...
Facebook Interview Question 2 asm 2 days

You are given an integer N and an integer M. You are supposed to write a method void findBestCoinsThatMinimizeAverage(int N, int M) that prints the best collection of N coins that minimize the average number of minimum coins needed to generate values from 1 to M. So, if M = 100, and N = 4, then if we use the set {1, 5, 10, 25} to generate each value from 1 to 100, so that for each value the number of coins are minimized, i.e. 1 = 1 (1 coin), 2 = 1 + 1 (2 coins),..., 6 = 1 + 5 (2 coins), ..., ...

Amazon Interview Question for Software Engineer/Developer (More than 5 Years) about Linked Lists 13 kirthu 2 days
struct node
{
    int data;
    struct node *next;
    struct node *next_larger;
}

initially next_larger of every node is point to NULL.
now write a c code which set all node's next_larger pointer.
where next_largest point to the next larger then its own value and largest value node's next_larger pointer points to NULL

i.e.
if LL is 3->1->5->6->4
then 3's next_larger points to 4
and 1's next_larger points to 3
and 5's next_lar...

Amazon
Maximum Sum Increasing Subsequence Problem 6 geeksforgeeks 3 days

How to know that the problem can be solved by greedy method or Dynamic method ???

For this problem how will we decide which of the above algorithm to use :-

[b]We are given a sequence of n positive numbers a1, . . . , an. Give an algorithm which finds the increasing subsequence of a1, . . . , an with the maximal sum. (For example on input 1, 101, 2, 3, 100, 4, 5 your algorithm should output 1, 2, 3, 100.)[/b]

FB interview question 4 akshayjohri 4 days

Given a function bool Zoo(int x) and its called for y times , how you will generate the true with probability x/y times .
lest say if x = 65 & y=100, how will you generate true with probability 65/100. You can represent true by 1 and false by 0.
Can sb please, help me in approaching this problem.

Testing of factorial of a number 3 akshayjohri 4 days

Given a simple program designed to take inputs of integers from 1-1000 and to output the factorial value of that number, how would you test this program? You do not have access to the code. Please be as specific as possible

MS interview question 2 geek4u 4 days

Given a list of words and a dictionary with many words. The dictionary may or may not include the the given list of words. From the given list of words,you need to print only those words which are present in dictionary.
Mention time complexity.

MS interview question 1 freakCoder 4 days

Given a set of numbers from 1 to n^2, generate subsets consisting of n numbers such that each subset has one and only one matching number from any other subset

The max number of sub-sets is n squared + n

An example is as follows:
n = 3
n squared set = 1, 2, 3, 4, 5, 6, 7, 8, 9

sub-set 1 = 1, 2, 3
sub-set 2 = 1, 4, 7
sub-set 3 = 1, 5, 9
sub-set 4 = 1, 6, 8
sub-set 5 = 2, 5, 8
sub-set 6 = 2, 4, 9
sub-set 7 = 2, 6, 7
sub...

[closed] Google Interview Question 3 geeksforgeeks 5 days

Given an array having positive integers, find a continous subarray which adds to a given number.

LIS in nlogn time 2 kartik 1 week

How to solve the longest increasing subsequence problem in nlogn time?

tree to file 1 Dheeraj 1 week

function to write a tree to file and another function to read tree from file.

Count internal nodes in a binary tree 2 kartik 1 week

how to count internal nodes in a binary tree?

combine elements of an array, so as to minimize weights. 6 rohanag 1 week

This was a question asked in interview street at a code sprint.

Jonny'y father has purchased him a new toy. The beauty of the toy is that it comes in N components and Jonny can join them in ways he like to make powerful superheroes.

Joining two toy components require certain effort which equal the sum of the weights of the two components. Little jonny desperate to make his new superhero as fast as possible.

Given the initial weights of the toy components help Jonny build ...