Interview Practice Basic – Depth First Traversal

There are 4 ways to do a depth first traversal, depends on how you would like to do it.

Read more...

How to Change the Computer Name in Ubuntu

1. Open a terminal window. 2. At the input prompt you will see this structure: “` nicholas@computer-name:~$ _ “` 3. So you have to edit the hostname file: “` sudo nano /etc/hostname “` 4. When prompted, enter the administrator password and hit Enter. 5. The hostname file will open, showing the current computer name. Replace the…

Read more...

No solution stacks listed in elastic beanstalk configuration

It is how you do the elastic beanstalk configurations. eb init You would be very frustrated when you can select no available solution stacks… Select a solution stack. Available solution stacks are: Select (1 to 0): It is because the credentials you use don’t have administrator rights. Go to Identity and Access Management (IAM) and add…

Read more...

Interview Practice Extra 07 – Universal Value Binary Tree

Question Design an algorithm to verify that a tree is a universal value binary tree. Universal value binary tree means all value in that tree is the same. Solution There is two approach for this problem. One is with recursive function and another is with iterative function. For this problem, iterative function makes simpler answer. However,…

Read more...

Interview Practice Extra 06 – Vending Machine

Question This is an actual question I encountered in an Amazon phone interview in November 2013. You are going to design the money changing algorithm for a vending machine. That is, after any purchase, the machine makes change to users with a combination of coins. And the machine only have 3 types of coins: nickel…

Read more...

Interview Practice Extra 04 – Remove Node from Singly Linked List

Question How do you remove a node from a singly linked list, given only that node? Head node is not given. Solution Set next of this node to the next of the next node. node->next = node->next->next; Reference Glassdoor

Read more...

Interview Practice 28 – Counting One in Binary Expression

Question Given a number, find the number of 1 in the number’s binary expression. For example, binary express of 10 is 1010. So the number of 1 in it is 2. Solution To solve this, we can check each bit by shifting the bits one by one. 1. 1010 -> check 0 2. 101 -> check…

Read more...

Interview Practice 22 – Card Guessing

Question Consider there are 4 blue and 4 red cards. Host gets 2 cards randomly, no one knows what cards they are. Then he places 2 random cards at the forehead of each player A, B and C. Players do not know the color of their own cards, but know those of other players. They…

Read more...

Interview Pizzle 1 – Find the Heavier Marble

Question You have 9 marbles. 8 marbles weigh 1 ounce each, & one marble weighs 1.5 ounces. You are unable to determine which is the heavier marble by looking at them. You have a weighing scale that consists of 2 pans, but the scale is only good for 2 total weighings. How can you determine which marble is the heaviest…

Read more...

Interview Practice Extra 02 – Duplicates in List

Question Write an algorithm to remove duplicated node from a linked list. Solution There are many ways to do it. For the first one, as the simplest one, we could use 2 loops to compare each element with all other elements. However, this takes forever: O(n²). The second way Reference http://www.geeksforgeeks.org/remove-duplicates-from-an-unsorted-linked-list/

Read more...