Posts

Showing posts from December, 2011

[Amazon]Data structure for Car Parking

Design a data structure which can be used efficiently for simulating car parking.It can have three different operations... 1 car_in 2 car_leave 3 Reset all

[MS]All combination of a string

Write a code to find r-combination of a String of length n. Ex: for String "abcd"  Combinations are:  ""      "a"  "b"   "ab"  "c"   "ac"   "bc"   "abc"   "d"  "ad"  "bd"    "abd"   "cd"   "acd"   "bcd"   "abcd" 

Insertion in cyclic linked list

Given a node from a cyclic linked list which has been sorted, write a function to insert a value into the list such that it remains a cyclic sorted list. The given node can be any single node in the list.

[MS]Serialize and Deserialize a string

There are  multiple api's for serializing and de-serializing strings while communicating from one process to another.Json is one of the most famous.Write your own api which will serialize a list of string and deserialize the list into individual string.

[inmobi]Handshake at the party

If there are  n  number of people invited in a party, who can shake hands with one another (where  n  > 1 ). After sometime host says that there is always a pair of people who has shake hands with the same number of people.How he came to know.

second largest number in minimum comparison

You have an array of numbers, you need to find the second largest number in the array in minimum number of comparisons.

Solve the Equation

Solve the equation:          p *e - x + q *sin( x ) + r *cos( x ) + s *tan( x ) + t * x 2 + u = 0         where 0 <= x <= 1 . p,q,r,s,t,u are variables.(where 0 <= p , r <= 20 and -20 <= q , s , t <= 0 ). For each set of input, there should be a line containing the value of x , correct upto 4 decimal places, or the string " No solution ", whichever is applicable. eg: Input 0 0 0 0 -2 1 1 0 0 0 -1 2 Output: 0.7071 No Solution