aboutsummaryrefslogtreecommitdiff
path: root/other/count_and_say.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'other/count_and_say.cpp')
-rw-r--r--other/count_and_say.cpp26
1 files changed, 0 insertions, 26 deletions
diff --git a/other/count_and_say.cpp b/other/count_and_say.cpp
deleted file mode 100644
index a1086b4..0000000
--- a/other/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);
-}