一品网
  • 首页

2109. 向字符串添加空格


水题

class Solution {
public:
    string addSpaces(string s, vector<int>& spaces) {
        int len = s.length();
        string ret = "";
        int i = 0, j = 0;
        while(i < len)
        {
            while(j < spaces.size() && spaces[j] == i)
                ret += ' ', j++;
            ret += s[i++];
        }
        return ret;


        
    }
};
每日一题

相关


【LeetCode每日一题】员工的重要性

【LeetCode每日一题】整数反转

【python】Leetcode每日一题-森林中的兔子

【python】Leetcode每日一题-132模式

【每日一题】【链表】2021年11月20日-141. 环形链表

每日一题-Day31-删除链表的倒数第n个节点

每日一题·暑假 week1

【每日一题】【栈】【递归】【遍历】2021年12月1日-94. 二叉树的中序遍历

# 每日题目-1.6:每日一题+49+50

【每日一题】【list转int数组】【Lambda的简化-方法引用】2022年1月15日-NC45 实现二

【每日一题】【找到位置返回&升序数组中第K大就是n-K小】2022年1月17日-NC88 寻找第K

【每日一题】【map操作】【滑动窗口所需元素】2021年12月22日-76. 最小覆盖子串

标签

一品网 冀ICP备14022925号-6