Search Results

6 matches found for 'dynamic programming'

Find the maximum min path

... 0, float('inf')) return result Solution (Optimized) An optimization is to use dynamic programming, as the previous solution will repeatedly visit blocks that were visited before.

Perfect Squares

... read off of the cache to save some performance. A better optimization than the former is to use dynamic programming -- that is, a bottom-up solution. In this optimization, instead of opting for recursion, we use a 2D array to pre-compute values, and use the recurrence relation formula above as the basis to populate the entire 2D array.

Counting the path of sums

... the Latin word memorandum, meaning "to be remembered". We can use memoization, or alternatively, dynamic programming, to make our algorithm faster. Basically, we are going to store the running total values into a hash table as we visit each node in the tree.

Decode number of ways

... the string input, contains only digits and may contain leading zero(s). Approach This is a dynamic programming problem because the results of a previously decoded subproblem can contribute to solve the current subproblem.

Greedy Algorithms

... picked for all of the previous steps remain the same. Greedy algorithms are not the same as dynamic programming, simply because in dynamic programming, you may re-visit previous steps in order to build the most optimal global answer.

Algorithm Interview Problems

Welcome This page contains solutions to common interview problems that may be encountered. Arrays Longest Substring Without Repeating Characters Rotate a 2D Matrix Buy/Sell Two Stocks Merge Intervals Next Permutation Random Permutation Replace all occurrences of a space with a string Linked Lists Reversing sublists of singly linked lists Cycles in singly linked lists Overlapping singly linked lists Merging two sorted singly linked lists Merge k sorted lists Recursion Counting the path of sums Money Denominations Phone Number Mnemonics Unique Permutation Dynamic Programming Perfect Squares Find the Maximum Min Path Binary Trees Tree Symmetry Iterative In-Order Traversal of a Binary Tree Construct a Binary Tree from Pre-Order Traversal and In-Order Traversal BST Validate a BST Binary Heaps Merge k sorted lists Graphs Find a path in a maze from start to finish Flip colors in a matrix Search Search in a rotated sorted array Find the Duplicate Number Greedy Algorithms Queue Reconstruction By Height Trie Build a Trie in Python Invariant Compute the max.