MCPcopy Create free account
hub / github.com/VanjaRo/LeetCode / findMedianSortedArrays

Function findMedianSortedArrays

tasks/4.go:14–23  ·  view source on GitHub ↗
(nums1 []int, nums2 []int)

Source from the content-addressed store, hash-verified

12}
13
14func findMedianSortedArrays(nums1 []int, nums2 []int) float64 {
15 nums1 = append(nums1, nums2...)
16 sort.Ints(nums1)
17 medInd := len(nums1) / 2
18 if len(nums1) == medInd*2 {
19 return float64(nums1[medInd]+nums1[medInd-1]) / 2
20 } else {
21 return float64(nums1[medInd])
22 }
23}
24
25// func findMedianSortedArrays(nums1 []int, nums2 []int) float64 {
26// merged := []int{}

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected