impl Solution { pubfnmin_height_shelves(books: Vec<Vec<i32>>, shelf_width: i32) -> i32 { let (n, mut i, mut j) = (books.len(), 0, 0); letmut dp = vec![std::i32::MAX; n]; while i < n { let (mut w, mut h) = (0, 0); j = i; while j < n { w += books[j][0]; if w > shelf_width { break; } h = cmp::max(h, books[j][1]); let val = match i { 0 => 0, _ => dp[i - 1] }; dp[j] = cmp::min(dp[j], val + h); j += 1; } i += 1; }