Complete the code to initialize the maximum revenue vector with zeros.
let mut max_revenue = vec![[1]; n + 1];
The maximum revenue vector should start with zeros because initially, no revenue is earned.
Complete the code to iterate over all rod lengths from 1 to n.
for length in 1..=[1] {
We iterate from 1 to n inclusive to calculate maximum revenue for each rod length.
Fix the error in the code to update the maximum revenue for the current length.
max_revenue[length] = max_revenue[length].max(prices[i - 1] + max_revenue[[1]]);
The remaining rod length after cutting is length - i, so we use that to get the max revenue for the leftover piece.
Fill both blanks to complete the inner loop iterating over possible first cut lengths.
for [1] in 1..=[2] {
The inner loop variable i represents the first cut length, iterating from 1 to the current rod length.
Fill all three blanks to complete the function signature and return statement.
fn rod_cutting(prices: &[i32], [1]: usize) -> [2] { // implementation [3] }
The function takes the rod length n as usize, returns i32 revenue, and returns max_revenue[n] at the end.
