【Leetcode_easy】830. Positions of Large Groups
problem
830. Positions of Large Groups
solution1:
class Solution { public: vector<vector<int>> largeGroupPositions(string S) { vector<vector<int>> res; int start = 0, end = 0; for(int i=1; i<S.size(); ++i) { if(S[i]==S[i-1]) end = i; else if(S[i]!=S[i-1]) { if(end-start>=2) res.push_back({start, end}); start = i; end = i; } } if(S.back()==S[S.size()-2] && end-start>=2) res.push_back({start, end});//err... return res; } };
参考
1. Leetcode_easy_830. Positions of Large Groups;
2. grandyang;
完
各美其美,美美与共,不和他人作比较,不对他人有期待,不批判他人,不钻牛角尖。
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步