Simple Easy Approach
IntuitionThe problem requires splitting a message into parts such that each part includes a suffix in the format <part/total> and the total length of each part
# Intuition
The problem requires splitting a message into parts such that each part includes a suffix in the format <part/total> and the total length of each part does not exceed the given limit. The challenge lies in dynamically adjusting the number of characters available for the message as the suffix grows in length when the number of parts crosses thresholds (e.g., from 9 to 10, or 99 to 100). This necessitates a two-step approach: first, determine the total number of parts required, and then construct the output while respecting the constraints.

# Approach
**Initialization:**
- Start with the smallest suffix length (<1/1>, 5 characters) and calculate the available characters for the message in each part.
- If the available characters are less than zero (limit too small for any message), return an empty array.

**Determine Total Parts:**

- Iterate through the message, consuming available characters per part and incrementing the part count.
- When the part count reaches a threshold (e.g., 10, 100), adjust the suffix length by adding 2 characters and recalculate the available characters.
- If the limit becomes too small for any part due to increased suffix length, return an empty array.

**Construct the Output:**
- Use the total number of parts calculated in the previous step to split the message.
- For each part, append the appropriate suffix in the <part/total> format and adjust the number of characters taken from the message accordingly.
- Ensure no part exceeds the limit and properly concatenate the suffix to each substring.

**Return the Result:**
- Return an array containing all the parts with the message segments and their respective suffixes.

This approach ensures the message is split efficiently while accounting for the dynamic changes in suffix length. It also handles edge cases, such as when the message is too long to fit even with minimal suffix adjustments.


# Code
```java []
class Solution {
    public String[] splitMessage(String message, int limit) {
       // Calculate the total number of parts needed and handle dynamic suffix length
int parts = 0;  // Total number of parts needed for the message
int suffixLen = 5;  // Minimum suffix length for "<1/1>" format
int index = 0;  // Current index of the message

int target = 10;  // Threshold for increasing suffix length (e.g., from 9 to 10, 99 to 100)
int available = limit - suffixLen;  // Characters available in each part after accounting for suffix

// If the limit is too small to fit even the minimum suffix, return an empty array
if (available <= 0) return new String[] {};

// Step 1: Determine the total number of parts required
while (index < message.length()) {
    index += available;  // Move the index forward by the number of available characters
    parts++;  // Increment the number of parts

    // Check if we've hit a target threshold where the suffix length increases
    if (parts == target) {
        // Adjust the index to account for extra characters required due to the increased suffix length
        index = index - target - 1;

        // Update the target for the next threshold (e.g., 10 -> 100)
        target *= 10;

        // Increase the suffix length by 2 as it grows with the number of digits in "total parts"
        suffixLen += 2;

        // Recalculate the available characters per part
        available = limit - suffixLen;

        // If the available characters become zero, splitting is not possible
        if (available <= 0) return new String[] {};
    }
}

// Reset the index for the next loop
index = 0;

// Step 2: Split the message into parts and construct the output
String[] output = new String[parts];  // Initialize the array to hold all parts

for (int part = 1; part <= parts; part++) {
    // Construct the suffix for the current part (e.g., "<1/3>", "<2/3>")
    StringBuilder builder = new StringBuilder();
    builder.append("<");
    builder.append(part);
    builder.append("/");
    builder.append(parts);
    builder.append(">");

    // Recalculate the available characters per part after appending the suffix
    available = limit - builder.length();

    // If the remaining part of the message fits in the current part, take it
    if (index + available > message.length()) {
        output[part - 1] = message.substring(index).concat(builder.toString());
    } else {
        // Otherwise, take the available characters and move the index forward
        output[part - 1] = message.substring(index, index += available).concat(builder.toString());
    }
}

// Return the array of split message parts
return output;

    }
}
```
['Java']