Get the App
SLTechnology News&Howtos  ›  Development  › 

How to find the median of two positive ordinal arrays

Shulou Source: shulou.com Published: 2022-06-03 06:11:49 10月03日 Update

This article introduces the knowledge of "how to find the median of two positive ordinal arrays". Many people will encounter this dilemma in the operation of actual cases. next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Search for the median description of two positive ordinal arrays

Difficulty: difficulty

Give two positive ordered (from small to large) arrays nums1 and nums2 of sizes m and n, respectively. Please find out and return the median of these two positive ordinal arrays.

Example 1:

Input: nums1 = [1p3], nums2 = [2] output: 2.00000 explain: merge array = [1mem2p3], median 2

Example 2:

Input: nums1 = [1jue 2], nums2 = [3jue 4] output: 2.50000 explain: merge array = [1Jing 2 Jing 3 Jing 4], median (2 + 3) / 2 = 2.50000

Example 3:

Input: nums1 = [0jue 0], nums2 = [0je 0] output: 0.00000

Example 4:

Input: nums1 = [], nums2 = [1] output: 1.00000

Example 5:

Input: nums1 = [2], nums2 = [] output: 2.00000

Tip:

Nums1.length = = mnums2.length = = n0

Tags: Two median array subscript complexity complexity output even example length input coordinates odd done pointer time result no three position Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Redmi Shulou Information MariaDB MySQL