Skip to content

Commit

Permalink
Time: 65 ms (82.40%) | Memory: 56.8 MB (71.94%) - LeetSync
Browse files Browse the repository at this point in the history
  • Loading branch information
ShatilKhan committed Mar 9, 2024
1 parent f560169 commit 8d3e2fe
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions 2634-minimum-common-value/minimum-common-value.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @param {number[]} nums1
* @param {number[]} nums2
* @return {number}
*/
var getCommon = function(nums1, nums2) {
let common = Infinity;
let i = 0, j = 0;
while(i < nums1.length && j < nums2.length){
if(nums1[i] === nums2[j]){
common = nums1[i];
break;
}else if (nums1[i] < nums2[j]){
i++;
}else {
j++;
}
}
return common !== Infinity ? common : -1;
};

0 comments on commit 8d3e2fe

Please sign in to comment.