Skip to content

Instantly share code, notes, and snippets.

@ksloginov
Created October 6, 2021 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksloginov/e43730736199c17d85fe4304b0582fbb to your computer and use it in GitHub Desktop.
Save ksloginov/e43730736199c17d85fe4304b0582fbb to your computer and use it in GitHub Desktop.
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