Greedy Algorithm to find Minimum number of Coins | C # program to find minimum number of denominations ; All denominations of Indian Currency ; Initialize result ; Traverse through all denomination ; Find denominations ; Print result ; Driver code
using System ; using System . Collections . Generic ; class GFG { static int [ ] deno = { 1 , 2 , 5 , 10 , 20 , 50 , 100 , 500 , 1000 } ; static int n = deno . Length ; static void findMin ( int V ) { List < int > ans = new List < int > ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { while ( V >= deno [ i ] ) { V -= deno [ i ] ; ans . Add ( deno [ i ] ) ; } } for ( int i = 0 ; i < ans . Count ; i ++ ) { Console . Write ( " ▁ " + ans [ i ] ) ; } } public static void Main ( String [ ] args ) { int n = 93 ; Console . Write ( " Following ▁ is ▁ minimal ▁ number ▁ " + " of ▁ change ▁ for ▁ " + n + " : ▁ " ) ; findMin ( n ) ; } }