1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 17:56:55 +02:00
LeetCode/rs/minimum-common-value.rs

12 lines
274 B
Rust
Raw Normal View History

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)
}
}