mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-01-13 02:38:37 +08:00
10 lines
211 B
C++
10 lines
211 B
C++
#include <string>
|
|
|
|
class Solution {
|
|
public:
|
|
int mirrorDistance(int n) {
|
|
std::string s = std::to_string(n);
|
|
std::reverse(s.begin(),s.end());
|
|
return std::abs(n - std::stoi(s));
|
|
}
|
|
}; |