当前位置:网站首页>761. Special Binary Sequences
761. Special Binary Sequences
2022-08-10 06:35:00 【anieoo】
Original title link: 761. Special Binary Sequence

solution
class Solution {public:static bool cmp(const string &a, const string &b) {return a > b;}string makeLargestSpecial(string s) {if(s.size() <= 2) return s;int cnt = 0, left = 0;vector subs;for (int i = 0; i < s.size(); ++i) {if (s[i] == '1') {++cnt;}else {--cnt;if (cnt == 0) {subs.push_back("1" + makeLargestSpecial(s.substr(left + 1, i - left - 1)) + "0");left = i + 1;}}}sort(subs.begin(), subs.end(), cmp);string ans;for(auto &c : subs) ans += c;return ans;}}; 边栏推荐
猜你喜欢
随机推荐
Screen post-processing: Sobel operator to achieve edge detection
Introduction to KDE Framework
OpenGL学习笔记(LearnOpenGL)-第四部分 着色器
交换机的功能和ipv4
网页安全证书错误但无法安装证书的解决办法
Elementary Structure
QScroller的QScrollerProperties参数研究
排序二叉树代码
Qt绘制椭圆曲线的角度问题(离心角和旋转角)
UnityShader入门精要-unity shader基础
Unity血条跟随对象
Simplest character device driver
socket实现进程间通信
UE 游戏模式
MySQL 免安装版/解压版的安装与配置(Win & Unix & Linux)
OpenGL学习笔记(LearnOpenGL)-第三部分 绘制矩形
Qt使用私有接口绘制窗口阴影
UnityShader入门精要-阴影
强化学习_12_Datawhale深度确定性策略梯度
2022河南萌新联赛第(五)场:信息工程大学 F - 分割草坪
![[Network Security] Practice AWVS Range to reproduce CSRF vulnerability](/img/7f/f08e429e3d8ede03a1c1754e256f99.png)








