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

rs: add «2540. Minimum Common Value»

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2024-03-09 11:39:50 +01:00
parent fe9f5ac9da
commit 46088cf458
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -0,0 +1,11 @@
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)
}
}