※ 引述《JerryChungYC (JerryChung)》之铭言:
: https://leetcode.com/problems/adding-spaces-to-a-string
: 2109. Adding Spaces to a String
: 在指定index插空格
: Example 1:
: Input: s = "LeetcodeHelpsMeLearn", spaces = [8,13,15]
: Output: "Leetcode Helps Me Learn"
: Example 2:
: Input: s = "icodeinpython", spaces = [1,5,7,9]
: Output: "i code in py thon"
: Example 3:
: Input: s = "spacing", spaces = [0,1,2,3,4,5,6]
: Output: " s p a c i n g"
: Constraints:
: 1 <= s.length <= 3 * 10^5
: s 只有大小写英文字母
: 1 <= spaces.length <= 3 * 10^5
: 0 <= spaces[i] <= s.length - 1
: spaces内的值是严格递增
我以为是考双指针
随便写写赢过90%
又水了一天
Java code: