Dynamic Programming and Greedy
30 problems to practice.
Paint Fence
1. You are given a fence with n posts and each post can be painted with one of them k colours 2. Y...
Paint House
1. You are given N houses, each house can be painted with 3 different colours: red, blue or green...
Fibonacci-dp
1. You are given a number n. 2. You are required to print the nth element of fibonnaci sequence....
Climb Stairs
1. You are given a number n, representing the number of stairs in a staircase. 2. You are on the 0t...
Climb Stairs With Variable Jumps
1. You are given a number n, representing the number of stairs in a staircase. 2. You are on the 0t...
Climb Stairs With Minimum Moves
1. You are given a number n, representing the number of stairs in a staircase. 2. You are on the 0t...
Min Cost In Maze Traversal
1. You are given a number n, representing the number of rows. 2. You are given a number m, represen...
Goldmine
1. You are given a number n, representing the number of rows. 2. You are given a number m, represen...
Target Sum Subsets - Dp
1. You are given a number n, representing the count of elements. 2. You are given n numbers. 3. Yo...
Coin Change Combination
1. You are given a number n, representing the count of coins. 2. You are given n numbers, represent...
Coin Change Permutations
1. You are given a number n, representing the count of coins. 2. You are given n numbers, represent...
Zero One Knapsack
1. You are given a number n, representing the count of items. 2. You are given n numbers, represent...
Unbounded Knapsack
1. You are given a number n, representing the count of items. 2. You are given n numbers, represent...
Fractional Knapsack - Official
1. You are given a number n, representing the count of items. 2. You are given n numbers, represent...
Count Binary Strings
1. You are given a number n. 2. You are required to print the number of binary strings of length n...
Arrange Buildings
1. You are given a number n, which represents the length of a road. The road has n plots on it's eac...
Count Encodings
1. You are given a string str of digits. (will never start with a 0) 2. You are required to encode...
Count A+b+c+ Subsequences
1. You are given a string str. 2. You are required to calculate and print the count of subsequences...
Maximum Sum Non Adjacent Elements
1. You are given a number n, representing the count of elements. 2. You are given n numbers, repres...
Paint House - Many Colors
1. You are given a number n and a number k separated by a space, representing the number of houses a...
Tiling With 2 * 1 Tiles
1. You are given a number n representing the length of a floor space which is 2m wide. It's a 2 * n...
Tiling With M * 1 Tiles
1. You are given a number n and a number m separated by line-break representing the length and bread...
Friends Pairing
1. You are given a number n, representing the number of friends. 2. Each friend can stay single or...
Partition Into Subsets
1. You are given a number n, representing the number of elements. 2. You are given a number k, repr...
Buy And Sell Stocks - One Transaction Allowed
1. You are given a number n, representing the number of days. 2. You are given n numbers, where ith...
Buy And Sell Stocks - Infinite Transactions Allowed
1. You are given a number n, representing the number of days. 2. You are given n numbers, where ith...
Buy And Sell Stocks With Transaction Fee - Infinite Transactions Allowed
1. You are given a number n, representing the number of days. 2. You are given n numbers, where ith...
Buy And Sell Stocks With Cooldown - Infinite Transaction Allowed
1. You are given a number n, representing the number of days. 2. You are given n numbers, where ith...
Buy And Sell Stocks - Two Transactions Allowed
1. You are given a number n, representing the number of days. 2. You are given n numbers, where ith...
Buy And Sell Stocks - K Transactions Allowed
1. You are given a number n, representing the number of days. 2. You are given n numbers, where ith...