2119. A Number After a Double Reversal 發表於 2023-02-13 | 分類於 leetcode problemsolution1234567891011121314151617class Solution {public: int reverse(int num){ int ret = 0; while(num){ ret*=10; ret+=(num%10); num/=10; } cout<<ret<<endl; return ret; } bool isSameAfterReversals(int num) { return reverse(reverse(num)) == num; }}; analyze time complexity O(1) space complexity O(1)