You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enumLocation{case row(Int)case column(Int)}func greatestRowOrColumnSum(in arr:[[Int]])->(Int,Location){varmax=(sum:0, location:Location.row(0))
for (index, row) in arr.enumerated(){letrowSum= row.reduce(0,+)
if rowSum > max.sum {
max =(rowSum,.row(index))}}
for columnIndex in 0..<arr[0].count {varcolumnSum=0
for rowIndex in 0..<arr.count {
columnSum +=arr[rowIndex][columnIndex]}
if columnSum > max.sum {
max =(columnSum,.column(columnIndex))}}return max
}