3447. Clear Digits
My accepted C++ solution to LeetCode problem 3447, Clear Digits, running in 0ms.
- Difficulty: Easy
- C++
- Runtime 0ms
- Memory 8.5MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
C++
Accepted on LeetCode — runtime 0ms, memory 8.5MB, accepted 2025-12-27.
class Solution {
public:
string clearDigits(string s) {
string result;
for (char c : s) {
if (isdigit(c)) {
if (!result.empty()) result.pop_back();
} else {
result += c;
}
}
return result;
}
};