国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Leetcode 2540. Minimum Common Value

2023-01-28 16:28 作者:您是打尖兒還是住店呢  | 我要投稿

Given two integer arrays?nums1?and?nums2, sorted in non-decreasing order, return?the?minimum integer common?to both arrays. If there is no common integer amongst?nums1?and?nums2, return?-1.

Note that an integer is said to be?common?to?nums1?and?nums2?if both arrays have?at least one?occurrence of that integer.

?

Example 1:

Input: nums1 = [1,2,3], nums2 = [2,4]Output: 2Explanation: The smallest element common to both arrays is 2, so we return 2.

Example 2:

Input: nums1 = [1,2,3,6], nums2 = [2,3,4,5]Output: 2Explanation: There are two common elements in the array 2 and 3 out of which 2 is the smallest, so 2 is returned.

?

Constraints:

  • 1 <= nums1.length, nums2.length <= 105

  • 1 <= nums1[i], nums2[j] <= 109

  • Both?nums1?and?nums2?are sorted in?non-decreasing?order.

Accepted

21,559

Submissions

39,937

因為2個數(shù)組是已經(jīng)排好序的,所以我們不需要去hashmap或者set去處理,只要從頭開始去遍歷即可的;

Easy題目;

Runtime:?2 ms, faster than?86.18%?of?Java?online submissions for?Minimum Common Value.

Memory Usage:?72.9 MB, less than?61.45%?of?Java?online submissions for?Minimum Common Value.


Leetcode 2540. Minimum Common Value的評論 (共 條)

分享到微博請遵守國家法律
宾阳县| 永顺县| 永安市| 邻水| 贵德县| 略阳县| 宜宾市| 兴宁市| 济宁市| 博罗县| 隆尧县| 铁岭市| 中江县| 藁城市| 彰化县| 白城市| 贺州市| 大港区| 黎城县| 海宁市| 吴川市| 绥化市| 柘荣县| 科尔| 广宗县| 耒阳市| 文山县| 洪雅县| 昌图县| 县级市| 翁牛特旗| 耿马| 孝义市| 万宁市| 五家渠市| 苍梧县| 福海县| 汉中市| 绥棱县| 安康市| 许昌市|