reverse the words in a sentence
Sigiloso
The previous java code it is not the best code, as it use split, StringBuilder it uses extra memory and extra time But simply it can be solved by converting the given string to a char[] then reverse the whole array in n/2 operation then start with 2 pointers from the beginning of the string ptr1 and ptr2, ptr1 is moving with step 1, while ptr2 stops when meet the first letter and when ptr1 meets a delimiter then reverse the characters between ptr2 and ptr1 in (ptr1-ptr2)/2 operation, and when the current character at ptr1 is a delimiter then ptr2 is updated with the value of ptr1 this solution is more efficient than the previous one, and will work with O(1) space and O(n) time