Please help me to solve this sum.
Leetcode doubt easy
Okay so what you can do to solve this problem is:
- Count number of spaces
- then count number of words
- if the number number of spaces%(number of words-1)==0
this means you can evenly distribute spaces, and you can do that - But if it’s not equal to 0 & number of spaces%(number of words-1)==k then you have to first distribute equal spaces and then add k extra space at the end of the string.
You can do it using string STL function if you are submitting it using c++, then you can take reference from here
All inbuilt functions of strings are mentioned here
http://www.cplusplus.com/reference/string/string/
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.