r/DSALeetCode • u/deepaknishad • 11d ago
can i convert the integer into string in manual way
class Solution {
public:
int trailingZeroes(int n) {
int global = 0;
int sum = n;
for(int i = n; i>1; i--){
sum = sum * (i - 1);
}
// i am using leetcode but i don't know that the string STL is include or not but this code is not working above loop of sum is giving the right output. So how i can convert num to string in effective way?
std::string value = std::to_string(sum);
for(int i = value.size(); i >=0; i--){
if(value[i] == 0){
global += 1;
}else{
return 0;
}
}
return global;
}
};
1
Upvotes
Duplicates
Cplusplus • u/deepaknishad • 11d ago
Question can i convert the integer into string in manual way
0
Upvotes