Dynamic Programming

//Dynamic Programming
­

Dynamic Programming Theory

Introduce what is and when to use dynamic programming.

November 14th, 2015|Categories: DS and Algorithms, Dynamic Programming, Recursion|Tags: , |

Dynamic Programming Example: Longest Common Subsequence

Introduce a classic dynamic programming problem: Longest Common Subsequence (LCS)

November 14th, 2015|Categories: DS and Algorithms, Dynamic Programming|Tags: , |

Dynamic Programming Example: The Knapsack Problem

Introduce a classic dynamic programming problem: The Knapsack Problem

November 14th, 2015|Categories: DS and Algorithms, Dynamic Programming|Tags: , |

[Leetcode] Triangle

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

November 14th, 2015|Categories: Array, DS and Algorithms, Dynamic Programming|Tags: , , , |

[Leetcode] Unique Paths

Help the robot to find all the unique paths from (0,0) to (m,n)

November 14th, 2015|Categories: DS and Algorithms, Dynamic Programming|Tags: , , , |

[Leetcode] Unique Paths II

Help the robot to find all the unique paths from (0,0) to (m,n) with obstacles

November 17th, 2015|Categories: DS and Algorithms, Dynamic Programming, Graph|Tags: , , , |

[Leetcode] Word Break

Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.

November 14th, 2015|Categories: DS and Algorithms, Dynamic Programming|Tags: , , , |

[Leetcode] Climbing Stairs

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

November 14th, 2015|Categories: DS and Algorithms, Dynamic Programming|Tags: , , , |

[Leetcode] Unique Binary Search Trees

Given n, how many structurally unique BST's (binary search trees) that store values 1...n?

November 24th, 2015|Categories: DS and Algorithms, Dynamic Programming, Tree|Tags: , , , , |

[Leetcode] Maximal Square

Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.

November 26th, 2015|Categories: DS and Algorithms, Dynamic Programming|Tags: , , , |

[Leetcode] House Robber

Determine the maximum amount of money you can rob tonight :)

December 1st, 2015|Categories: DS and Algorithms, Dynamic Programming|Tags: , , , |

[Leetcode] House Robber II

This is an extension of the previous problem: House Robber.

December 4th, 2015|Categories: DS and Algorithms, Dynamic Programming|Tags: , , |

[Leetcode] Range Sum Query Immutable

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.

December 11th, 2015|Categories: Array, DS and Algorithms, Dynamic Programming|Tags: , , , |

[Leetcode] Best Time to Buy and Sell Stock

Given an array for which the ith element is the price of a given stock on day i, design an algorithm to find the maximum profit if you were only permitted to complete at most one transaction.

December 12th, 2015|Categories: Array, DS and Algorithms, Dynamic Programming|Tags: , , , |

[Leetcode] Best Time to Buy and Sell Stock II

Given an array for which the ith element is the price of a given stock on day i, design an algorithm to find the maximum profit if you may complete as many transactions as you like.

December 13th, 2015|Categories: Array, DS and Algorithms, Dynamic Programming|Tags: , , , , |

[Leetcode] Best Time to Buy and Sell Stock III

Given an array for which the ith element is the price of a given stock on day i, design an algorithm to find the maximum profit if you may complete at most 2 transactions.

December 13th, 2015|Categories: DS and Algorithms, Dynamic Programming|Tags: , , , |

[Leetcode] Best Time to Buy and Sell Stock IV

Given an array for which the ith element is the price of a given stock on day i, design an algorithm to find the maximum profit if you may complete at most k transactions.

December 14th, 2015|Categories: DS and Algorithms, Dynamic Programming|Tags: , , , , |

[Leetcode] Best Time to Buy and Sell Stock with Cooldown

Given an array for which the ith element is the price of a given stock on day i, design an algorithm to find the maximum profit if you need to cooldown before another purchase.

December 14th, 2015|Categories: DS and Algorithms, Dynamic Programming|Tags: , , , |