3 Doors and Angel

Problem : You are given a choice of three doors by an Angel. You can choose only one of the doors among the three. Out of these three doors two contains nothing and one has a jackpot. After you choose one of the doors angel  reveals one of the other two doors behind which there Read More →

Amazon interview – Set 2

I am 2011 passed out from IIIT Hyderabad. I would like to contribute for CrazyforCode by sharing my experience of Amazon Interview process. This was for a SDE position in Bangalore. I had one online test. After that 4 round of F2F interviews and I cracked it. Round 1 Q1. Find next inorder predecessor in Read More →

Explain advantages of MyISAM over InnoDB?

MyISAM manages nontransactional tables. It provides high-speed storage and retrieval, as well as fulltext searching capabilities. Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type. An .frm file stores the table format. The data file has an .MYD (MYData) extension. The index file Read More →

3 Mislabeled Jars

3 mislabeled jars of Apple and Orange

Puzzle: This problem is also called Jelly Beans problem. This is the most commonly asked interview puzzle. You have 3 jars that are all mislabeled. One jar contains Apple, another contains Oranges and the third jar contains a mixture of both Apple and Oranges. You are allowed to pick as many fruits as you want Read More →

Find the smallest positive number missing from an unsorted array

You are given an unsorted array with both positive and negative elements. You have to find the smallest positive number missing from the array in O(n) time using constant extra space. Example: Input = {2, 3, 4, 6, 8, -1, -3} Output = 1 Input = { 1, 3, -7, 6, 8, 1, -5, 5 Read More →

Sort an array of 0s,1s,2s

You are given an array of 0s 1s and 2s in random order. Sort the array so the o,1 and 2 are segregated. This problem is similar to Dutch national Flag problem.   Method 1: Use count sort logic. Complexity: O(N) Method 2: 1. Sort the array treating {0} as one group and {1, 2} Read More →

Adobe Interview – Set 1

I am Aman gupta. I passed out in 2010. I recently appeared for the adobe interview. I had one written test. It consisted questions of C/C++,English and logical reasoning. I cleared the written test and then got call for face to face interview. Round 1: 1. Given a router which takes a ip as input Read More →

Lowest common ancestor in a Binary Tree.

Problem : Given a binary tree, find the lowest common ancestor of two given nodes in the tree. Lowest Common Ancestor: The lowest common ancestor (LCA) of two nodes v and w is defined as the lowest node in tree that has both v and w as descendants (where we allow a node to be Read More →

Missing number in an array

You are given an array of n – 1 unique numbers in the range from 0 to n – 1. There is only one number missing in the range from 0 to n – 1 . You need to find the missing number. We know that sum of of numbers from 0 – n-1  is Read More →

Print a Square Matrix in Spiral Form

spiral

Given a N*N square matrix. Write a code to print it in spiral order. Time Complexity : O(N^2)

3 Doors and Heaven

3 door and heaven puzzle

Problem: A person dies, and he arrives at the gate to heaven. There are 3 doors in the heaven. One of the door leads to heaven, second one leads to a 1-day stay at hell and then back to the gate and the third one leads to a 2 day stay at hell and then Read More →

Amazon interview – Set 1

Round 1(Telephonic) 1. Given a binary tree and an integer x, return whether the binary tree has a path from root to a leaf whose values sum to x. 2. Gievn a binary tree and return all root to leaf node pathss row,col and value. 3. He then asked me to give test cases for Read More →