Tap here to switch tabs
Problem
Submissions

Problem: Split Message Based on Limit

Try to solve the Split Message Based on Limit problem.

Statement

You are given a string message and an integer limit.

You need to split message into kk parts such that each part is appended with a suffix formatted as "<i/k>", where:

  • k represents the total number of parts into which the message is divided.

  • i represents the 11 based index of the current part, satisfying 1≤i≤k1 \leq i \leq k.

The splitting must satisfy the following conditions:

  • The total length of each part, including its appended suffix, is at most limit.

  • Concatenating the contents of all kk parts (excluding their suffixes) in order reconstructs the original message.

  • The total number of parts kk is minimized.

Return an array of strings representing the split parts in order. If it is impossible to split message to satisfy all conditions, return an empty array.

Constraints:

  • 1≤1 \leq message.length ≤104\leq 10^4

  • message consists only of lowercase English letters and ' '.

  • 1≤1 \leq limit ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Split Message Based on Limit

Try to solve the Split Message Based on Limit problem.

Statement

You are given a string message and an integer limit.

You need to split message into kk parts such that each part is appended with a suffix formatted as "<i/k>", where:

  • k represents the total number of parts into which the message is divided.

  • i represents the 11 based index of the current part, satisfying 1≤i≤k1 \leq i \leq k.

The splitting must satisfy the following conditions:

  • The total length of each part, including its appended suffix, is at most limit.

  • Concatenating the contents of all kk parts (excluding their suffixes) in order reconstructs the original message.

  • The total number of parts kk is minimized.

Return an array of strings representing the split parts in order. If it is impossible to split message to satisfy all conditions, return an empty array.

Constraints:

  • 1≤1 \leq message.length ≤104\leq 10^4

  • message consists only of lowercase English letters and ' '.

  • 1≤1 \leq limit ≤104\leq 10^4