当前位置:网站首页>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;}}; 边栏推荐
猜你喜欢
随机推荐
Qt滚动条(QScrollBar)圆角样式问题跟踪
UE 游戏模式
2022 Henan Mengxin League No. 5: University of Information Engineering J-AC Automata
unityFps射击
腾讯云宋翔:Kubernetes集群利用率提升实践
老手也常误用!详解 Go channel 内存泄漏问题
Can‘t find bundle for base name jdbc, locale zh_CN解决方法
Talking about 3 Common Shadow Rendering Techniques in Games (3): Shadow Mapping
QEMU guest与host通过网络通信——bridge/hostfwd/guestfwd
order by注入与limit注入,以及宽字节注入
Please pay attention to me, thank you.
UnityShader入门精要-立方体纹理、反射、折射、菲涅尔反射
Text-to-Image最新论文、代码汇总
Unity扩展编辑器EditorWindow 小玩意(一)
什么是代理ip?市面上好用的代理软件有哪些
ebp/栈帧/call stack
第11章 数据库的设计规范【2.索引及调优篇】【MySQL高级】
OpenGL学习笔记(LearnOpenGL)-第二部分 绘制三角形
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
UnityShader入门精要-纹理动画、顶点动画









