# Jump Game II

Problem description:
Level: medium

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of jumps.

Example:
Given array A = [2,3,1,1,4]
The minimum number of jumps to reach the last index is 2. (Jump 1 step from index 0 to 1, then 3 steps to the last index.)
Continue reading

# Jump Game

Problem Description:
Level: medium
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index.

Example
A = [2,3,1,1,4], return true.
A = [3,2,1,0,4], return false.
Continue reading

# Climbing Stairs

Problem description
Level: easy

You are climbing a stair case. It takes n steps to reach to the top.

Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

Example
Given an example n=3 , 1+1+1=2+1=1+2=3
return 3
Continue reading

# Dynamic Programming Elements

What is Dynamic Programming?
Dynamic Programming (DP) is a method for solving a complex problem by breaking it down into a collection of simpler subproblems in a recursive manner. DP is an algorithmic technique which is usually based on a recurrent formula and one (or some) starting states. A sub-solution of the problem is constructed from previously found ones. DP solutions have a polynomial complexity which assures a much faster running time than other techniques.
Continue reading

# Triangle problem

Problem description:
Level: easy
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.

Example
For example, given the following triangle

The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11).
Continue reading

# Queue example in Java

Java provides us Queue interface, where we can keep and handle elements before processing. Except the methods that Collection provides, it also supports some basic operations in order to simulate the classic queue structure. Each of these operations exists in two forms:

1. if a method fails, an exception is thrown. This form includes add(), remove() and element() methods.
2. if a method fails, a special value is returned (null or false). This form contains offer(), poll() and peek() operations.
Continue reading

# Binary Tree Level Order Traversal

Problem description
Level: medium
Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).

Example
Given binary tree {3,9,20,#,#,15,7},

# Lowest Common Ancestor

Problem Description
level: medium

Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes.
The lowest common ancestor is the node with largest depth which is the ancestor of both nodes.
Continue reading

# Binary Tree Maximum Path Sum Problem

Problem Description
Level: medium
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree.

Example
Given the below binary tree:

return 6
Continue reading