Solution Review: Big (O) of Nested Loop with Subtraction
This review provides a detailed analysis of how to solve the Big O of Nested Loop with Subtraction challenge.
Solution
Press + to interact
Rust 1.40.0
fn main(){let n = 10;let mut sum = 0;let pie = 3.14;for i in (1..n).rev().step_by(3){println!("{}", pie);for j in (0..n).rev(){sum += 1;}}println!("{}",sum);}
See the following table for a detailed line-by-line analysis of the calculation of time complexity.
let n = 10; |
|
let mut sum = 0; |
|
let pie = 3.14; |
|
for i in (1..n).rev().step_by(3) |
|
println!("{}", pie); |
|
for j in (0..n).rev() |
Access this course and 1400+ top-rated courses and projects.