Code Monkey home page Code Monkey logo

algorithm's Introduction

问题:给定不同面额的硬币 coins 和一个总金额 amount。计算可以凑成总金额所需的组合数。如果没有任何一种硬币组合能组成总金额,返回 0。 
例 1:  coins = [1, 2, 5], amount = 5, result =4 (5=2+2+1=2+1+1+1=1+1+1+1)
例 2:  coins = [2], amount = 3, result = 0
说明:每种硬币的数量是无限的。

解法
一看到找零问题,马上反应用动态规划,只要知道<amount金额的解,就能马上得出金额为amount的解

时间复杂度
时间空间都是O(nm)

algorithm's People

Contributors

zerohou avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.