c**********e 发帖数: 2007 | 1 1. Reverse a string, for example, change "abcde" to "edcba".
Optimize space, optimize time.
2. Reverse words, for example, change "I love Alice very much"
to "much very Alice love I". Optimize space, optimize time. | v********w 发帖数: 136 | 2 1.for i=1:n/2 swap a[i] and a[n-i]
2. reverse the whose string as 1, then reverse each word
【在 c**********e 的大作中提到】 : 1. Reverse a string, for example, change "abcde" to "edcba". : Optimize space, optimize time. : 2. Reverse words, for example, change "I love Alice very much" : to "much very Alice love I". Optimize space, optimize time.
|
|