Problem Brief
Prepare Notification
FULLTIMEOA
See Microsoft online assessment and hiring insightsPrepare a notification of the given message which will be displayed on a mobile device. The message is made of words separated by single spaces. The length of the notification is limited to K characters. If the message is too long to be displayed fully, some words from the end of the message should be cropped, keeping in mind that:
Functin Description:
Complete function prepareNotification in the editor.
Function prepareNotification has the following parameters:
String message & int k
Returns:
The notification to display, which has no more than K chars, as described above.1Example 1
Input
message = "And now here is my secret", K = 15
Output
"And now..."
Explanation
2Example 2
Input
message = "There is an animal with four legs", K = 15
Output
"There is an ..."
Explanation
The function should return "There is an...".
3Example 3
Input
message = "super dog", K = 4
Output
"..."
Explanation
The function should return "...".
4Example 4
Input
message = "how are you", K = 20
Output
"how are you"
Explanation
The function should return "how are you".
Constraints
Limits and guarantees your solution can rely on.
K is an integer within the range [3..500]the length of string message is within the range [1..500]string message is made of English letters (a-z, 'A-Z) and spacesmessage does not contain spaces at the beginning or at the endwords are separated by a single space (there are never two or more consecutive spaces)