fn elements_in_both_vecs(u: &[i32], v: &[i32]) -> Option<Vec<i32>> {
    let mut res = vec![];

    // Iterate and push duplicate values
    for &idx in u.iter() {
        if v.contains(&idx) {
            res.push(idx);
        }
    }

    // Return None if res is empty
    if !res.is_empty() {
        Some(res)
    } else {
        None
    }
}
/// Return Some(vec) of elements in both u and v, else None
Return Some(vec) of elements in both u and v, else None
Return Some ( vec ) of elements in both u and v else None
fn elements_in_both_vecs(u: &[i32], v: &[i32]) -> Option<Vec<i32>> {
    let mut res = vec![];
    // Iterate and push duplicate values
    for &idx in u.iter() {
        if v.contains(&idx) {
            res.push(idx);
        }
    }
    // Return None if res is empty
    if !res.is_empty() {
        Some(res)
    } else {
        None
    }
}
fn elements_in_both_vecs ( u : & [ i32 ] , v : & [ i32 ] ) -> Option < Vec < i32 > > { let mut res = vec ! [ ] ; // Iterate and push duplicate values for & idx in u . iter ( ) { if v . contains ( & idx ) { res . push ( idx ) ; } } // Return None if res is empty if ! res . is_empty ( ) { Some ( res ) } else { None } }
Return Some(vec) of elements in both u and v, else None
Return Some ( vec ) of elements in both u and v else None
u
&[i32]
v
&[i32]
u
&[i32]
v
&[i32]