Am a Software Developer , worked on financial domain projects , experienced in backed end development technologies like java, spring boot, microservice. Later I did certification on AWS ,Blockchain.
Hello>>>Shiva .... can we achieve tagetsum using Set collection of Rust....
Here , i tried with that Set approach..... it returns me empty array.... could you please help me out on this!!!!
fn targetTwoSum(vecval: Vec, tagetSum:i32)-> Vec{
let mut sets: HashSet = HashSet::new();
for i in vecval{
let potential_match = tagetSum - i;
// println!("the potential_match : {}",potential_match);
if let Some(pos) = sets.get(&potential_match){
println!("entering in if");
return vec![i,*pos];
}
sets.insert(potential_match);
}
println!("the set values are : {:?}",sets);
vec![]
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello>>>Shiva .... can we achieve tagetsum using Set collection of Rust....
Here , i tried with that Set approach..... it returns me empty array.... could you please help me out on this!!!!
fn targetTwoSum(vecval: Vec, tagetSum:i32)-> Vec{
let mut sets: HashSet = HashSet::new();
for i in vecval{
let potential_match = tagetSum - i;
// println!("the potential_match : {}",potential_match);
if let Some(pos) = sets.get(&potential_match){
println!("entering in if");
return vec![i,*pos];
}
sets.insert(potential_match);
}