File tree 3 files changed +22
-0
lines changed
3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ leetcode practise solution in rust
101
101
| 496| [ Next Greater Element I] ( src/_0496_next_greater_element_i.rs ) |
102
102
| 503| [ Next Greater Element II] ( src/_0503_next_greater_element_ii.rs ) |
103
103
| 509| [ Fibonacci Number] ( src/_0509_fibonacci_number.rs ) |
104
+ | 518| [ Coin Change 2] ( src/_0518_coin_change_2.rs ) |
104
105
| 520| [ Detect Capital] ( src/_0520_detect_capital.rs ) |
105
106
| 532| [ K-diff Pairs in an Array] ( src/_0532_kdiff_pairs_in_an_array.rs ) |
106
107
| 543| [ Diameter of Binary Tree] ( src/_0543_diameter_of_binary_tree.rs ) |
Original file line number Diff line number Diff line change
1
+ struct Solution ;
2
+
3
+ impl Solution {
4
+ pub fn change ( amount : i32 , coins : Vec < i32 > ) -> i32 {
5
+ let mut dp: Vec < i32 > = vec ! [ 0 ; amount as usize + 1 ] ;
6
+ dp[ 0 ] = 1 ;
7
+
8
+ for coin in coins {
9
+ for i in coin..=amount {
10
+ dp[ i as usize ] += dp[ i as usize - coin as usize ] ;
11
+ }
12
+ }
13
+
14
+ dp[ amount as usize ]
15
+ }
16
+ }
17
+
18
+ #[ test]
19
+ fn test ( ) { }
Original file line number Diff line number Diff line change @@ -206,6 +206,8 @@ mod _0509_fibonacci_number;
206
206
//
207
207
mod _0516_longest_palindromic_subsequence;
208
208
//
209
+ mod _0518_coin_change_2;
210
+ //
209
211
mod _0520_detect_capital;
210
212
//
211
213
mod _0532_kdiff_pairs_in_an_array;
You can’t perform that action at this time.
0 commit comments