葉林
Linked with GitHub
# LeetCode - 0038. Count and Say ### 題目網址:https://leetcode.com/problems/count-and-say/ ###### tags: `LeetCode` `Medium` `字串` ```cpp= /* -LeetCode format- Problem: 38. Count and Say Difficulty: Medium by Inversionpeter */ class Solution { public: string countAndSay(int n) { int counts; string result = "1", buffer; while (--n) { counts = 1, buffer = ""; for (int i = 1; i != result.size(); ++i) if (result[i] != result[i - 1]) buffer += char('0' + counts), buffer += result[i - 1], counts = 1; else ++counts; result = buffer + char('0' + counts) + result[result.size() - 1]; } return result; } }; ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up