#K84447. Split String by Asterisk
Split String by Asterisk
Split String by Asterisk
You are given a non-empty string ( S ) that contains one or more asterisks (''). Your task is to determine if the string can be split into two non-empty substrings such that each substring contains exactly one occurrence of the character ''.
The splitting method is defined as follows: Let ( i ) be the index of the first occurrence of '' and ( j ) be the index of the last occurrence of '' in ( S ). If ( i = j ) (i.e. there is only one '' in the string), or if the first '' is the first character or the last '' is the last character of ( S ), then the answer is "No". Otherwise, output two substrings separated by a single space, where the left substring consists of the part of ( S ) from the beginning up to (but not including) the last '' and the right substring is the part starting from the last '*' to the end of ( S ).
It is guaranteed that the input is given from standard input (stdin) and the result should be output to standard output (stdout).
inputFormat
A single line containing a non-empty string ( S ) which may include the character '*' along with other characters. There are no extra spaces at the beginning or end of the input.
outputFormat
Output the two substrings separated by a space if a valid split exists; otherwise, output "No".## sample
abc*def*gh
abc*def *gh