Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Coding problems. In any programming languages.. Pleae need help You are given some text containing characters which could be English letters, spaces, commas (,), full

Coding problems. In any programming languages.. Pleae need help

You are given some text containing characters which could be English letters, spaces, commas (,), full stops (.), and question marks (?), that a user would like to send as an SMS, and a limit specifying the maximum number of characters a single message can contain. Your task is to split the text into the lowest number of SMS message required to fit all characters in text. Each message should contain some part of the text, followed by the suffix , where y is the total number of messages, and x is the number for the current message (starting from 1). The suffix is considered a part of the message. So, the total length of each message includes the length of the suffix.

Text can only be split into different SMS messages no spaces, and spaces used for splitting should not include be in either part of the split. For example, hello, world can only be split into hello, and world.

Return an array containing all SMS messages. If its impossible to split the text into different messages based on the limit for each message, return an empty array. If multiple solutions with the same number of messages are possible, earlier message should be as long as possible and latter messages should be decreasing in length.

For example,

For text = a b c and limit = 6, the output should be

smsSplitter(text,limit) = [a, b, c ]2,3>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Android Graphics

Authors: Wallace Jackson

1st Edition

1430257857, 978-1430257851

More Books

Students also viewed these Programming questions

Question

What is the mode?

Answered: 1 week ago