diff --git "a/lcof/\351\235\242\350\257\225\351\242\23066. \346\236\204\345\273\272\344\271\230\347\247\257\346\225\260\347\273\204/README.md" "b/lcof/\351\235\242\350\257\225\351\242\23066. \346\236\204\345\273\272\344\271\230\347\247\257\346\225\260\347\273\204/README.md" index 57c7b1ca3c6b7..3bcd9cd7fef85 100644 --- "a/lcof/\351\235\242\350\257\225\351\242\23066. \346\236\204\345\273\272\344\271\230\347\247\257\346\225\260\347\273\204/README.md" +++ "b/lcof/\351\235\242\350\257\225\351\242\23066. \346\236\204\345\273\272\344\271\230\347\247\257\346\225\260\347\273\204/README.md" @@ -188,6 +188,33 @@ public class Solution { } ``` +#### Swift + +```swift +class Solution { + func constructArr(_ a: [Int]) -> [Int] { + let n = a.count + guard n > 0 else { return [] } + + var ans = [Int](repeating: 1, count: n) + + var left = 1 + for i in 0.. diff --git "a/lcof/\351\235\242\350\257\225\351\242\23066. \346\236\204\345\273\272\344\271\230\347\247\257\346\225\260\347\273\204/Solution.swift" "b/lcof/\351\235\242\350\257\225\351\242\23066. \346\236\204\345\273\272\344\271\230\347\247\257\346\225\260\347\273\204/Solution.swift" new file mode 100644 index 0000000000000..e33738cfd93e6 --- /dev/null +++ "b/lcof/\351\235\242\350\257\225\351\242\23066. \346\236\204\345\273\272\344\271\230\347\247\257\346\225\260\347\273\204/Solution.swift" @@ -0,0 +1,22 @@ +class Solution { + func constructArr(_ a: [Int]) -> [Int] { + let n = a.count + guard n > 0 else { return [] } + + var ans = [Int](repeating: 1, count: n) + + var left = 1 + for i in 0..