Leetcode 之Count and Say(35)
生活随笔
收集整理的這篇文章主要介紹了
Leetcode 之Count and Say(35)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
很有意思的一道題,不好想啊。
string getNext(string &s){char start = s[0];int count = 0;stringstream ss;for (int i = 0; i < s.size(); i++){if (start == s[i]){count++;}else{ss << count << start;count = 1;start = s[i];}}ss << count << start;return ss.str();}string countAndSay(int n){string s = "1";for (int i = 0; i < n; i++)s = getNext(s);} View Code?
轉載于:https://www.cnblogs.com/573177885qq/p/5528060.html
總結
以上是生活随笔為你收集整理的Leetcode 之Count and Say(35)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 团队计划(5.25)
- 下一篇: 设置控件全局显示样式appearance