diff --git a/LeetCode Solutions/leetcode 38 b/LeetCode Solutions/leetcode 38 new file mode 100644 index 00000000..a65cb8f9 --- /dev/null +++ b/LeetCode Solutions/leetcode 38 @@ -0,0 +1,25 @@ +leetcode 18-10-2022 +daily challanges +class Solution { +public: + string countAndSay(int n) { + string o("1"); + string t; + for (int c, m, j, i = 2; i <= n; ++i) { + c = 1; + m = o.length() - 1; + for (j = 0; j < m; ++j) { + if (o[j] != o[j + 1]) { + t.append(string(1, c + '0')); + t.append(string(1, o[j])); + c = 1; + } + else c++; + } + t.append(string(1, c + '0')); + t.append(string(1, o[j])); + o = move(t); + } + return o; + } +};