JobHunting版 - Reverse characters of each word in a sentence |
|
|
|
|
|
r*******k 发帖数: 1423 | 1 Read more: http://www.businessinsider.com/8-mind-bending-interview-questions-that-google-asks-its-engineers-2012-7?op=1#ixzz3BAjAab00
ANSWER: There's a more clever way to do it than just flipping each character.
ANSWER: There's a more clever way to do it than just flipping each character.
Boonsri Dickinson, Business Insider
You can solve the problem iteratively — by basically plowing through each
character and moving it — but there's a clever way to solve it using
something called recursion.
This is basically what Google typically wants: Engineers who find the
smartest solution, not just a correct solution.
That breaks the problem into smaller problems of reversing each word and
then recombining them into a statement.
Read more: http://www.businessinsider.com/8-mind-bending-interview-questions-that-google-asks-its-engineers-2012-7?op=1#ixzz3BAjfvUEi | r*******k 发帖数: 1423 | 2 实在是没懂,为什么不能一个单词一个单词的reverse
不也是o(N)么?
搞成recursion的,就是好看点吧。。。
character.
character.
【在 r*******k 的大作中提到】 : Read more: http://www.businessinsider.com/8-mind-bending-interview-questions-that-google-asks-its-engineers-2012-7?op=1#ixzz3BAjAab00 : ANSWER: There's a more clever way to do it than just flipping each character. : ANSWER: There's a more clever way to do it than just flipping each character. : Boonsri Dickinson, Business Insider : You can solve the problem iteratively — by basically plowing through each : character and moving it — but there's a clever way to solve it using : something called recursion. : This is basically what Google typically wants: Engineers who find the : smartest solution, not just a correct solution. : That breaks the problem into smaller problems of reversing each word and
| s***5 发帖数: 2136 | 3 stupid engineers think recursion is free. | r*******k 发帖数: 1423 | 4 应该不至于
看了看解答,好像是链表的形式
不管了
【在 s***5 的大作中提到】 : stupid engineers think recursion is free.
|
|
|
|
|
|
|