Yahoo India Web Search

Search results

  1. leetcode.com › problems › coin-changeCoin Change - LeetCode

    Learn how to solve the coin change problem on LeetCode, a popular platform for coding interviews and challenges. Find the input, output, example, and constraints for this medium-level problem.

    • Discuss (999+)

      Coin Change - Level up your coding skills and quickly land a...

    • - LeetCode

      Can you solve this real interview question? - Level up your...

    • Solution

      Can you solve this real interview question? Coin Change -...

  2. Learn how to solve the coin change problem with dynamic programming and memoization. Given an array of coins and an amount of money, find the number of ways to make change.

    • Problem Statement
    • Explanation
    • Solution
    • GeneratedCaptionsTabForHeroSec

    Question: https://leetcode.com/problems/coin-change/ You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. You may assume that you have an inf...

    The problem is simple and relatable, we just need to break an amount into the change based on the coins we have, the special thing is that the number of coins in the change should be minimum i.e. there should not be any combination of coins available which has the number of coins less than your answer.

    So the first solution that came up in my mind was a greedy approach that I will sort the coins in descending order based on their values and try to include the biggest coin because it will decrease the amount by a bigger value and that can be filled by smaller coins so I'll get the minimum number of coins solution. Like as in Example 1: coins = [1,...

    Learn how to solve the coin change problem using dynamic programming and bottom-up approach. See the problem statement, example, algorithm, and C++ code implementation.

  3. Sep 21, 2021 · In this Leetcode Coin Change problem solution, You are given an integer array of coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount.

  4. class Solution {public: int coinChange (vector < int >& coins, int amount) {// dp[i] := the minimum number of coins to make up i vector < int > dp (amount + 1, amount + 1); dp [0] = 0; for (const int coin: coins) for (int i = coin; i <= amount; ++ i) dp [i] = min (dp [i], dp [i-coin] + 1); return dp [amount] == amount + 1?-1: dp [amount];}};

  5. Learn how to solve the Coin Change problem on LeetCode using dynamic programming. The problem is to find the minimum number of coins to make a given amount with a set of coins. See Python and C++ code examples.

  6. Coin Change is a Leetcode medium level problem. Let’s see the code, 322. Coin ChangeLeetcode Solution. Table of Contents. Problem. You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount.