Author Archives: Crazyadmin

17 Horses Puzzle

17 horses and 3 sons puzzle

Problem: A farmer wants to divide his 17 horses among his three sons. According to farmer the oldest son should get half of the horses,the middle son should get one third of the horses and the youngest son should get one ninth of the horses. When their father died they were not able to divide Read More →

Rotate linked list by K nodes

You are given a singly linked list, rotate the linked list counter-clockwise by k nodes. Where k is a given positive integer. i.e. if the given linked list is: 1->2->3->4->5 and k is 3, the list should be modified to: 4->5->1->2->3. Assume that k is smaller than the number of nodes in linked list. Steps: Read More →

Software AG interview – Set 1

I am 2010 passed out from MNITJ. I would like to contribute for CrazyforCode by sharing my experience of Software AG Interview process. This was for a SSE position in Bangalore. There was no written test. I had 3 round of F2F interviews and 1 HR interview. Round 1 Q1. Interface i = 20 Abstract Read More →

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 →

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 →

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 →