Tag view

#dynamic-programming

Cross-subject tag search for related interview cards.

Clear

Results update as you type. Press / to jump straight into search.

Tagged with dynamic-programming

5 cards

Coding Exercises Easy O(n)

Climbing Stairs

Each position depends on the previous two positions, so keep only the last two counts and build forward iteratively.

Return how many distinct ways there are to reach the top if you can climb 1 or 2 steps at a time.

Coding Exercises Medium O(amount * len(coins))

Coin Change

Initialize a DP array with an impossible sentinel value, set dp[0] to zero, and for each amount try every coin to update the cheapest reachable solution.

Given coin denominations and a target amount, return the minimum number of coins needed to make that amount or -1 if it is impossible.

Coding Exercises Medium O(n)

House Robber

Track the best result when including or excluding the current house. A rolling two-variable DP solution keeps the implementation compact.

Return the maximum amount you can rob from houses without robbing adjacent houses.