I executed the code as below. it was occurred a error with the title as you can see! I don't how to handle it
import UIKit
var str = "Hello, playground"
print("hello world!")
class Solution {
func findMedianSortedArrays(_ nums1: [Int], _ nums2: [Int]) -> Double {
let a = nums1.first!
let b = nums1.last!
let c = nums2.first!
let d = nums2.last!
if c >= a && c >= b {
let conbineArray = nums1 + nums2
let arrayCount = nums1.count + nums2.count
if arrayCount % 2 == 0 {
return Double((conbineArray[(arrayCount / 2) - 1] + conbineArray[arrayCount / 2]) / 2)
} else {
return Double(conbineArray[ ((arrayCount + 1) / 2) - 1])
}
}
if c <= a && d <= a {
let conbineArray = nums2 + nums1
let arrayCount = nums2.count + nums1.count
if arrayCount % 2 == 0 {
return Double((conbineArray[(arrayCount / 2) - 1] + conbineArray[arrayCount / 2]) / 2)
} else {
return Double(conbineArray[ ((arrayCount + 1) / 2) - 1])
}
}
let totalArray = nums1 + nums2
let sortedArray = totalArray.sorted(by: < )
if sortedArray.count % 2 == 0 {
return Double((sortedArray[(sortedArray.count / 2) - 1] + sortedArray[sortedArray.count / 2]) / 2)
} else {
return Double(sortedArray[ ((sortedArray.count + 1) / 2) - 1])
}
}
}
let b:[Int] = []
let a = [1]
let s = Solution()
s.findMedianSortedArrays(a, b)
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.
Comments
Post a Comment