Created
October 6, 2021 20:11
-
-
Save ksloginov/e43730736199c17d85fe4304b0582fbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
func findMedianSortedArrays(_ nums1: [Int], _ nums2: [Int]) -> Double { | |
let nums = (nums1 + nums2).sorted() | |
if nums.count % 2 == 1 { | |
return Double(nums[Int(nums.count / 2)]) | |
} | |
return Double(nums[Int(nums.count / 2) - 1] + nums[Int(nums.count / 2)]) / 2.0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment