File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 6
6
*/
7
7
8
8
class ProductExceptSelf {
9
- func productExceptSelf( nums: [ Int ] ) -> [ Int ] {
9
+ func productExceptSelf( _ nums: [ Int ] ) -> [ Int ] {
10
10
var res = [ Int] ( )
11
11
12
12
guard nums. count > 0 else {
@@ -23,7 +23,7 @@ class ProductExceptSelf {
23
23
return res
24
24
}
25
25
26
- private func _initLeft( nums: [ Int ] ) -> [ Int ] {
26
+ private func _initLeft( _ nums: [ Int ] ) -> [ Int ] {
27
27
var left = [ Int] ( )
28
28
left. append ( 1 )
29
29
@@ -34,13 +34,13 @@ class ProductExceptSelf {
34
34
return left
35
35
}
36
36
37
- private func _initRight( nums: [ Int ] ) -> [ Int ] {
38
- var right = Array ( count : nums . count , repeatedValue : 1 )
37
+ private func _initRight( _ nums: [ Int ] ) -> [ Int ] {
38
+ var right = Array ( repeating : 1 , count : nums . count )
39
39
40
- for i in ( nums. count - 2 ) . stride ( through: 0 , by: - 1 ) {
40
+ for i in stride ( from : nums. count - 2 , through: 0 , by: - 1 ) {
41
41
right [ i] = right [ i + 1 ] * nums[ i + 1 ]
42
42
}
43
43
44
44
return right
45
45
}
46
- }
46
+ }
You can’t perform that action at this time.
0 commit comments