@@ -74,7 +74,7 @@ len(M[a]) = len(message[j:j+k]) + len(<a/b>)
7474- Because ` message[j:j+k] ` cannot be empty, ` len(message[j:j+k]) >= 1 ` .
7575- ` len(b) >= len(a) >= 1 ` .
7676
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 ` .
7878
7979From the requirements:
8080
@@ -85,7 +85,7 @@ We have
8585
8686- ` len(M[a]) <= limit ` .
8787
88- => ` limit >= 5 ` .
88+ => ` limit >= 6 ` .
8989
9090- The maximum length of each message part is ` limit ` , so
9191
@@ -96,7 +96,7 @@ We have
9696
9797From the above analysis, the logic can be presented as below:
9898
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.
100100- Otherwise, iterate from 1 to len(message) and for each index ` a ` , we will check if it is possible to split ` message `
101101 into ` a ` parts that satisfies the requirements.
102102- If we find the number of total message parts, it is simple to build the output array.
@@ -112,7 +112,7 @@ import (
112112)
113113
114114func splitMessage (message string , limit int ) []string {
115- if limit < 5 {
115+ if limit < 6 {
116116 return []string {}
117117 }
118118
0 commit comments