Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions LeetCode Solutions/leetcode 38
Original file line number Diff line number Diff line change
@@ -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;
}
};