Skip to content

Instantly share code, notes, and snippets.

@fatihgokce
Created March 3, 2020 21:49
Show Gist options
  • Save fatihgokce/9af1cd6f032ce4d241dc9905f36ea2df to your computer and use it in GitHub Desktop.
Save fatihgokce/9af1cd6f032ce4d241dc9905f36ea2df to your computer and use it in GitHub Desktop.
fn find_missing(arr1:&[i32],arr2:&[i32])->Vec<i32>{
let mut n:Vec<i32>=Vec::new();
//let v: Vec<i32> = Vec::new();
let mut b:&[i32]=arr1;
let mut s:&[i32]=arr2;
if(arr2.len()>arr1.len()){
b=arr2;
s=arr1;
}
let mut flag=true;
for v1 in b.iter(){
flag=true;
for v2 in s.iter(){
if v1==v2{
flag=false;
break;
}
}
if flag==true{
n.push(*v1);
}
}
return n;
}
fn main() {
let result = find_missing(&[4,12,9,5],&[4,9,12,6,17,21]);
println!("misssing is {:?}", result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment