6
6
*/
7
7
8
8
class TextJustification {
9
- func fullJustify( words: [ String ] , _ maxWidth: Int ) -> [ String ] {
9
+ func fullJustify( _ words: [ String ] , _ maxWidth: Int ) -> [ String ] {
10
10
var res = [ String] ( )
11
11
var count = 0 , last = 0
12
12
@@ -15,7 +15,7 @@ class TextJustification {
15
15
}
16
16
17
17
for i in 0 ..< words. count {
18
- let wordLen = words [ i] . characters . count
18
+ let wordLen = words [ i] . count
19
19
20
20
if count + ( i - last) + wordLen > maxWidth {
21
21
var spaceNum = 0
@@ -40,7 +40,7 @@ class TextJustification {
40
40
return res
41
41
}
42
42
43
- fileprivate func buildLine( words: [ String ] , _ start: Int , _ end: Int , _ spaceNum: Int , _ extraNum: Int ) -> String {
43
+ fileprivate func buildLine( _ words: [ String ] , _ start: Int , _ end: Int , _ spaceNum: Int , _ extraNum: Int ) -> String {
44
44
var res = " "
45
45
var extraNum = extraNum
46
46
@@ -60,7 +60,7 @@ class TextJustification {
60
60
return res
61
61
}
62
62
63
- fileprivate func buildSpecialLine( words: [ String ] , _ start: Int , _ end: Int , _ lineLength: Int ) -> String {
63
+ fileprivate func buildSpecialLine( _ words: [ String ] , _ start: Int , _ end: Int , _ lineLength: Int ) -> String {
64
64
var res = " "
65
65
66
66
for i in start... end {
@@ -70,7 +70,7 @@ class TextJustification {
70
70
}
71
71
}
72
72
73
- for _ in res. characters . count..< lineLength {
73
+ for _ in res. count..< lineLength {
74
74
res += " "
75
75
}
76
76
0 commit comments