You are viewing a single comment's thread. Return to all comments →
My solution in golang:
func findMedian(arr []int32) int32 { var median []int32 sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] }) if len(arr)%2 == 0 { median = append(median, arr[len(arr)/2-1]) } else { median = append(median, arr[len(arr)/2]) } return median[0] }
Seems like cookies are disabled on this browser, please enable them to open this website
Find the Median
You are viewing a single comment's thread. Return to all comments →
My solution in golang: