当前位置:网站首页>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;}}; 边栏推荐
- XV6 swtch.S详解
- 关于Qt高频率信号槽合并的误解和方案
- Hypervisor, KVM, QEMU总结
- MVCC详解
- 如何在VMlogin中设置YiLu代理?
- 强化学习_05_DataWhale近端策略优化
- Unity2D动画生成操作(简单)
- webSocket教程
- NetKeeper(创翼)开WIFI方法——2018.5
- I would like to ask you guys, when FLink SQL reads the source, specify the time field of the watermark. If the specified field is in the grid
猜你喜欢

Mysql表数据在命令行窗口下中文乱码问题解决方法

强化学习_03_表格方法实践(CartPole-v0 And MontoCarlo)

直接跳转与间接跳转

NetKeeper(创翼)开WIFI方法——2018.5

Grammar Basics (Judgment Statements)

ES13 - ES2022 - The 123rd ECMA Congress approves the ECMAScript 2022 language specification

ES13 - ES2022 - 第 123 届 ECMA 大会批准了 ECMAScript 2022 语言规范

Qt借助隐藏控件和QSS绘制重复元素

修改 QtCreator 配置解决 “无法运行 rc.exe” 问题

webSocket教程
随机推荐
语法基础(判断语句)
Text-to-Image最新论文、代码汇总
Qt程序字体初始化引起的白屏问题
Unity2D动画生成操作(简单)
JS中初始化对象为null和空对象的区别
H3C文档NAT专题
动态代理-cglib
Qt使用私有接口绘制窗口阴影
ebp/栈帧/call stack
1413. 逐步求和得到正数的最小值
全网可达,交换机和路由器的配置,vlan
qemu and host share disk
Parallax Mapping: More Realistic Texture Detail Representation (Part 1): Why Use Parallax Mapping
高质量WordPress下载站模板5play主题
个人实现的可任意折叠QToolBox——AdvancedToolBox
强化学习_06_DataWhale深度Q网络
手机与雷电模拟器里如何使用YiLu代理?
【8月9日活动预告】Prometheus峰会
Elementary Structure
直接跳转与间接跳转