[LeetCode] Encode String with Shortest Length

1 · · Feb. 15, 2022, 4:39 a.m.
471. Encode String with Shortest Length Given a string s, encode the string such that its encoded length is the shortest. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. k should be a positive integer. If an encoding process does not make the string shorter, then do not encode it. If there are several solutions, return any of them. ...