1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-14 01:49:41 +01:00
LeetCode/rs/minimum-common-value.rs
Matej Focko 46088cf458
rs: add «2540. Minimum Common Value»
Signed-off-by: Matej Focko <mfocko@redhat.com>
2024-03-09 11:39:50 +01:00

11 lines
274 B
Rust

impl Solution {
pub fn get_common(xs: Vec<i32>, ys: Vec<i32>) -> i32 {
if xs.len() > ys.len() {
return Self::get_common(ys, xs);
}
xs.into_iter()
.find(|x| ys.binary_search(&x).is_ok())
.unwrap_or(-1)
}
}