[C++] 리트코드 Count and Say
·
Algorithm/HackerRank, LeetCode
class Solution { public: string countAndSay(int n) { if (n == 1) { return "1"; } string result = countAndSay(n - 1); //left Count right Num string currResult; char currNum = result[0]; int currCount = 0; for (int j = 0; j < result.length(); j++) { if (currNum == result[j]) { currCount++; } if (currNum != result[j]) { currResult += to_string(currCount) + currNum; currCount = 1; currNum = result[j..