aboutsummaryrefslogtreecommitdiff
path: root/other/perfect_squares.rs
diff options
context:
space:
mode:
Diffstat (limited to 'other/perfect_squares.rs')
-rw-r--r--other/perfect_squares.rs21
1 files changed, 0 insertions, 21 deletions
diff --git a/other/perfect_squares.rs b/other/perfect_squares.rs
deleted file mode 100644
index 3887e40..0000000
--- a/other/perfect_squares.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-use std::cmp::min;
-struct Solution;
-
-impl Solution {
- pub fn num_squares(n: i32) -> i32 {
- let mut dp: Vec<i32> = vec![std::i32::MAX; n as usize + 1];
- dp[0] = 0;
- for i in 1..(n as usize + 1) {
- let mut j: usize = 1;
- while j * j <= i {
- dp[i] = min(dp[i], dp[i - j * j] + 1);
- j += 1;
- }
- }
- dp[n as usize]
- }
-}
-
-fn main() {
- print!("{}", Solution::num_squares(12));
-}