https://kotlinlang.org logo
Title
u

user

07/16/2022, 10:41 PM
Converting Kotlin to swift get out of index error I a. trying to convert my Kotlin code to swift but I got an Index out of range error any help is appriatcted. Swift func getMaxBeauty(arr: [Int]) -> Int { // Write your code here let n = arr.count var beauty = 0 var leftMax = Array(arrayLiteral: n) leftMax[0] = arr[0] for i in 0...n { leftMax[i] = max(leftMax[i - 1], arr[i]) } var rightMin = Array(arrayLiteral: n) rightMin[n - 1] = arr[n - 1] for i in (n - 2)..