I have been trying to solve this problem in rust. I am able solve for the small inputs for the problem but I am unable to do for bigger inputs. I don't know how I can take so many inputs. I am sharing the link to the Problem: LINK. I am also sharing my code here:
use std::io;
fn main() {
let mut n: String = String::new();
match io::stdin().read_line(&mut n) {
Err(error) => eprintln!("Error: {}", error),
Ok(_) => (),
}
let n: u32 = n.trim().parse().unwrap();
// println!("{}", n);
// let mut num: Vec<u32> = vec![0; n];
let mut i: String = String::new();
match io::stdin().read_line(&mut i) {
Err(error) => eprintln!("Error: {}", error),
Ok(_) => (),
}
let mut sum: u128 = 0;
let p: &str = &i;
for s in p.split(' ').collect::<Vec<&str>>().into_iter() {
let s1: u128 = s.trim().parse().unwrap();
// num[(s1 as usize) - 1] = s1;
sum += s1;
// println!(" {} {}", s1, sum);
}
let mut s1: u128 = (n * (n + 1)) as u128;
s1 /= 2;
println!("{:?}", s1 - sum);
// println!("{:?}", num);
}
Please help with it.