@@ -74,7 +74,7 @@ len(M[a]) = len(message[j:j+k]) + len(<a/b>)
74
74
- Because ` message[j:j+k] ` cannot be empty, ` len(message[j:j+k]) >= 1 ` .
75
75
- ` len(b) >= len(a) >= 1 ` .
76
76
77
- => ` len(M[a]) = len(message[j:j+k]) + 3 + len(a) + len(b) >= 1 + 3 + 1 + 1 = 5 ` .
77
+ => ` len(M[a]) = len(message[j:j+k]) + 3 + len(a) + len(b) >= 1 + 3 + 1 + 1 = 6 ` .
78
78
79
79
From the requirements:
80
80
@@ -85,7 +85,7 @@ We have
85
85
86
86
- ` len(M[a]) <= limit ` .
87
87
88
- => ` limit >= 5 ` .
88
+ => ` limit >= 6 ` .
89
89
90
90
- The maximum length of each message part is ` limit ` , so
91
91
@@ -96,7 +96,7 @@ We have
96
96
97
97
From the above analysis, the logic can be presented as below:
98
98
99
- - If ` limit < 5 ` , it is impossible to split message as required, then return the empty string array immediately.
99
+ - If ` limit < 6 ` , it is impossible to split message as required, then return the empty string array immediately.
100
100
- Otherwise, iterate from 1 to len(message) and for each index ` a ` , we will check if it is possible to split ` message `
101
101
into ` a ` parts that satisfies the requirements.
102
102
- If we find the number of total message parts, it is simple to build the output array.
@@ -112,7 +112,7 @@ import (
112
112
)
113
113
114
114
func splitMessage (message string , limit int ) []string {
115
- if limit < 5 {
115
+ if limit < 6 {
116
116
return []string {}
117
117
}
118
118
0 commit comments