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
//Stack overflow: https://stackoverflow.com/questions/2680548/given-an-array-of-numbers-return-array-of-products-of-all-other-numbers-no-div func productOfAllExceptIndex(in arr:[Int])->[Int]{vartopArr=[Int](repeating:0, count: arr.count)varproduct=1
for i in 0..<arr.count {topArr[i]= product
product *=arr[i]}varbotArr=[Int](repeating:0, count: arr.count)
product =1
for i in (0..<arr.count).reversed(){botArr[i]= product
product *=arr[i]}varfinalArr=[Int]()
for i in 0..<arr.count {
finalArr.append(topArr[i]* botArr[i])}return finalArr
}