宋倩倩 发表于 2013-7-30 14:00:41

[google面试题]Write
 a 
function 
to
 reverse
 the
 order
 of
 words 
in 
a 
string
 in 
place.

淡写轻描 发表于 2013-7-30 14:18:17

Answer:Reverse the string by swapping the first character with the last character,these condcharacter with the second‐to‐last character,and soon.Then,go through the string looking for spaces,so that you find where each of the words is.Reverse each of the words you encounter by again swapping the first character with the last character,these condcharacter with these cond‐to‐last character,and soon.
页: [1]
查看完整版本: [google面试题]Write
 a 
function 
to
 reverse
 the
 order
 of
 words 
in 
a 
string
 in 
place.