📌 📄 内容摘要:
@ninijia 在 Leetcode每日一题练习 ------ 3163. 压缩字符串 III 中发帖
从Leetcode 每日一题练习继续讨论:
3163. 压缩字符串 III
3163. String Compression III
题解
本题读懂题意后其实并不难,就是一个单纯的字符串统计,从头遍历字符串,统计当前重复出现的字符个数,当个数达到9个时或者遇到新字符时就向comp字符串末尾添加当前重复字符的重复次数和字符本身。
代码
class Solution {
public:
string compressedString(string word) {
char num = '0';
char current = word[0];
string result;
for(auto ch:word){
if (ch == current){
if (nu...
────────── 链接信息 ──────────
🔗 论坛链接: linux.do
📎 访问地址: https://linux.do/t/topic/250030/1
─────────────────────────────
📢 来源:LINUX DO