无码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的評論 (共 條)

分享到微博請遵守國家法律
中超| 耒阳市| 阿荣旗| 马关县| 利川市| 巴青县| 安丘市| 武邑县| 阿坝县| 瓮安县| 周至县| 嘉义县| 南昌县| 文成县| 滨海县| 华蓥市| 扶沟县| 大宁县| 漠河县| 平顺县| 泾阳县| 咸阳市| 韩城市| 柳江县| 河北省| 休宁县| 澄城县| 县级市| 将乐县| 高阳县| 三亚市| 托里县| 阿克苏市| 芮城县| 南城县| 长阳| 嘉黎县| 贵溪市| 农安县| 萨迦县| 牙克石市|