diff options
Diffstat (limited to 'count_and_say.cpp')
-rw-r--r-- | count_and_say.cpp | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/count_and_say.cpp b/count_and_say.cpp deleted file mode 100644 index a1086b4..0000000 --- a/count_and_say.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - string countAndSay(int n) { - if (n == 0) - return ""; - string ans = "1"; - while (--n) { - string curr = ""; - for (int i = 0; i < ans.size(); i++) { - int count = 1; - while ((i + 1 < ans.size()) && (ans[i] == ans[i + 1])) - count++, i++; - curr += to_string(count) + ans[i]; - } - ans = curr; - } - return ans; - } -}; - -int main() { - Solution obj; - cout << obj.countAndSay(4); -} |