模板题目:Two Pointer (186 Reverse Words in a String II)
Given an input string , reverse the string word by word.
Input: [“t”,“h”,“e”," “,“s”,“k”,“y”,” “,“i”,“s”,” “,“b”,“l”,“u”,“e”]
Output: [“b”,“l”,“u”,“e”,” “,“i”,“s”,” “,“s”,“k”,“y”,” ",“t”,“h”,“e”]
reverse words, but now we got comma in that and we can’t do anything about the comma.
还是双指针 但是就是选择性跳过就完事了。
或者我们选择reverse each word.
由于代码过于简单 这里就不加多说。
做题的时候能想到双指针就可以了。

浙公网安备 33010602011771号