# Algorithm

##
0/1 Knapsack Problem Dynamic Programming
Paid
Members
Public

Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. Drawing graphint[] plot(int[

##
Dynamic Programming
Paid
Members
Public

Come up with a recursive functionMemorize the intermediate resultsMake it bottom up

##
Palindrome
Paid
Members
Public

Definition of Palindromeleft-to-right, and right-to-left, and it’s the same. For examples: Abba A man, a plan, a canal - Panama!SolutionYou need 2 pointers, one at the beginning, another one in the end. Move them one by one towards the center and check if it's palindrome. boolean check(String

##
Breathe First Traversal
Paid
Members
Public

In the iterative way You can only do breathe first traversal in iterative way. Though you can still make it recursive by calling itself in each loop, but you will not benefit from it. It is similar to doing depth first traversal, instead you use a FIFO queue to store

##
Depth First Traversal
Paid
Members
Public

There are 4 ways to do a depth first traversal, depends on how you would like to do it. Define Node static class Node { int value; Node left, right; } Depth First Recursive Traversal (Pre-order) static boolean depthFirstTraversal_preOrder(Node node) { if (node == null) return true; if (!visit(node)) return false;

##
Snapsack Problem
Paid
Members
Public

Snapsack problem refers to the situation you want to find a combination of items that can fill up a container. Each items should be attached with a value, and there should be a target value that means a container is filled up. For example, a container has 25 spaces and

##
Universal Value Binary Tree
Paid
Members
Public

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,

##
Vending Machine
Paid
Members
Public

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