#Leetcode2109 
So it was simple 
1. I created StringBuilder to appned new result in same output string
2. Traversed given string and space array together. 
used condition    if(i==space[j]) to append " "
note *j&lt;space.length
3. no extra space used.
#Leetcode2109