无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
海阳市| 奉节县| 古田县| 凉城县| 韶关市| 青海省| 浮山县| 尚志市| 东城区| 大丰市| 西充县| 泰和县| 广南县| 囊谦县| 长兴县| 阳朔县| 明星| 江门市| 乌兰浩特市| 五莲县| 安仁县| 玉田县| 和顺县| 寿阳县| 兖州市| 会昌县| 梧州市| 突泉县| 普格县| 布拖县| 宁蒗| 沧州市| 梨树县| 介休市| 扎囊县| 西畴县| 锡林郭勒盟| 三台县| 达日县| 枝江市| 乌恰县|