最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

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

分享到微博請遵守國家法律
镇安县| 崇左市| 东方市| 武义县| 永修县| 峡江县| 娄烦县| 富蕴县| 宜州市| 德清县| 乌什县| 麻城市| 土默特左旗| 城步| 汉寿县| 宿迁市| 洛川县| 瑞昌市| 云林县| 山西省| 昭通市| 安达市| 汶川县| 大城县| 邓州市| 墨脱县| 睢宁县| 开阳县| 家居| 横峰县| 隆子县| 灵丘县| 漳平市| 广汉市| 玛纳斯县| 民县| 弥渡县| 甘孜| 呼和浩特市| 榆社县| 共和县|