Cracking the Coding Interview: Fourth Edition (308 page e-book / PDF)
Delivered instantly as a PDF via email. For Software Engineers & SDETs
  • 150 programming interview questions and answers
  • 5 proven approaches to crack algorithm questions
  • 10 mistakes candidates make, and how to avoid them.
  • How to prepare for technical and behavioral questions without wasting your time!
"The BEST book for acing your interview. It helped me land my Microsoft job, and it was worth every penny!" - Ravi (Accepted at Microsoft, Amazon and Facebook) 30 Day Money Back Guarantee: Don't love the book? We'll give you your money back! More Info

Wednesday, April 28, 2010

Car is traveling

A car is traveling at a uniform speed.The driver sees a milestone showing a 2-digit number. After traveling for an hour the driver sees another milestone with the same digits in reverse order.After another hour the driver sees another milestone containing the same two digits. What is the average speed of the driver?

Ans

45 kmph

Father's age

Father's age is three years more than three times the son's age.After three years, father's age will be ten years more than twice the son's age. What is the father's present age?


Ans:
33 years.

General Questions

1- Why do you like to work with us?

2- What work are you expecting?

3- Tell me about any of your experience

Top command

What is the functionality of a top command?

Ans
Top command displays all the Linux tasks running at that particular time. It provides their running time and the resources used.

Array of size

Given an array of size n+1 which contains all the numbers from 1 to n. Find the number which is repeated in O(n) time. How do you proceed with the same with floating numbers from 0 to 1 instead of 1 to n?

Ans

The number appearing 2 times is (sum of all the numbers in the array) - (sum of the numbers from 1 to n). For floating numbers multiply it with 100 and proceed.

Two trains enter at the opposite

Two trains enter at the opposite sides of a tunnel of length L with speeds 'V'. A particle enters the tunnel at the same time with a speed 'v' and it vibrates in the tunnel[i.e. if it reaches the end of the tunnel then it comes back]. What is the position of the particle by the time the 2 trains meet?

Ans

If v<=2V then the position is (v*L)/(2*V) from the starting point else it is 2*L -(v*L)/(2*V) from the starting point.

Saturday, April 24, 2010

Amazon.com

Type: Public
On the web: http://www.amazon.com
Employees: 24,300
Employee growth: 17.4%

What started as Earth's biggest bookstore has rapidly become Earth's biggest anything store. Expansion has propelled Amazon.com in innumerable directions. Its main Web site offers millions of books, music, and movies (which still account for most of its sales), not to mention auto parts, toys, electronics, home furnishings, apparel, health and beauty aids, prescription drugs, and groceries. Also, shoppers can download books, games, MP3s, and films to their computers or handheld devices, including Amazon's own portable reader, the Kindle. Amazon also offers services and products, such as self-publishing, online advertising, a Web store platform, and a co-branded credit card. Amazon acquired Zappos.com in 2009.

Key numbers for fiscal year ending December, 2009:
Sales: $24,509.0M
One year growth: 27.9%
Net income: $902.0M
Income growth: 39.8%

Officers:
Chairman, President, and CEO: Jeffrey P. (Jeff) Bezos
SVP and CFO: Thomas J. (Tom) Szkutak
Senior Manager Business Development: Scott Merlino

Missing number

Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 1 number. Find the missing number.

Denominations of coins

You are given some denominations of coins in an array (int denom[])and infinite supply of all of them. Given an amount (int amount), find the minimum number of coins required to get the exact amount. What is the method called?

Maximum sum

Given an array all of whose elements are positive numbers, find the maximum sum of a subsequent elements with the constraint that no 2 numbers in the sequence should be adjacent in the array. So, 3 2 7 10 should return 13 (sum of 3 and 10) or 3 2 5 10 7 should return 15 (sum of 3, 5 and 7)

Polymorphism

Explain polymorphism. Provide an example.

Convert a decimal number

How do you convert a decimal number to its hexa-decimal equivalent. Give a C code to do so.

Array of size n

Given an array of size n, containing every element from 1 to n+1, except one. Find the missing element.

Second largest elemen

Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.

N red balls

Given n red balls and m blue balls and some containers, how would you distribute those balls among the containers such that the probability of picking a red ball is maximized, assuming that the user randomly chooses a container and then randomly picks a ball from that.

Write a function which

Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.

Merge Sort

What is the time and space complexities of merge sort and when is it preferred over quick sort?
What is a C array and illustrate how it is different from a list.
Given a cube of size n*n*n (i.e made up of n^3 smaller cubes), find the number of smaller cubes on the surface. Extend this to k-dimension.
You are given a dictionary of all valid words. You have the following 3 operations permitted on a word: delete a character, insert a character, replace a character. Now given two words - word1 and word2 - find the minimum number of steps required to convert word1 to word2. (one operation counts as 1 step.)
Given a string, find the first unrepeated character in it? Give some test cases.
Given an array of size n. It contains numbers in the range 1 to n. Find the numbers which aren’t present.
Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers.
Define Data Abstraction. What is its importance?
What are the 4 basics of OOP?