We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// stack을 활용하여 풀이 // 먼저 class Solution { public: string decodeString(string s) { stack<int> countStack; stack<string> resultStack; string current = ""; int k = 0; for (char c : s) { if (isdigit(c)) { k = k * 10 + (c - '0'); } else if (c == '[') { countStack.push(k); resultStack.push(current); k = 0; current = ""; } else if (c == ']') { int repeatTimes = countStack.top(); countStack.pop(); string temp = resultStack.top(); resultStack.pop(); for (int i = 0; i < repeatTimes; i++) { temp += current; } current = temp; } else { current += c; } } return current; } };
The text was updated successfully, but these errors were encountered:
fkdl0048
No branches or pull requests
The text was updated successfully, but these errors were encountered: