Suggestion for approach

In this Question, We need to print short name of the given string.
e.g. “Mohd Kafeel Khan” as “M. K. Khan”
I solved this using string and substring function of java in a for loop and taken a character.
My Solution Link
Is it good approach or I should solve this using array and take the first character after space?

Please give suggestions!

I think your approach is better

1 Like