---
# System prepended metadata

title: 2540. Minimum Common Value
tags: [Leetcode, Easy]

---

# 2540. Minimum Common Value
###### tags: `Leetcode` `Easy`
Link: https://leetcode.com/problems/minimum-common-value/description/
## Code
```java=
class Solution {
    public int getCommon(int[] nums1, int[] nums2) {
        int p1 = 0, p2 = 0;
        while(p1<nums1.length && p2<nums2.length){
            if(nums1[p1]<nums2[p2]) p1++;
            else if(nums1[p1]>nums2[p2]) p2++;
            else return nums1[p1];
        }
        return -1;
    }
}
```