当前位置:网站首页>7. Reverse integer integer
7. Reverse integer integer
2022-07-26 06:43:00 【DXB2021】
Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.
To give you one 32 Signed integer of bit x , Return to x The result of reversing the number part in .
If the integer after inversion exceeds 32 The range of signed integers of bits [−231, 231 − 1] , Just go back to 0.
Assume the environment does not allow you to store 64-bit integers (signed or unsigned).
Suppose the environment doesn't allow storage 64 An integer ( With or without sign ).
Example 1:
Input: x = 123
Output: 321
Example 1:
Input :x = 123
Output :321
Example 2:
Input: x = -123
Output: -321
Example 2:
Input :x = -123
Output :-321
Example 3:
Input: x = 120
Output: 21
Example 3:
Input :x = 120
Output :21
Example 4:
Input :x = 0
Output :0
Constraints: Tips :
-
<= x <=
- 1
C Language :
int reverse(int x){
long int r=0;
while(x)
{
if(r>INT_MAX/10||r<INT_MIN/10)
{
return 0;
}
r=r*10+x%10;
x=x/10;
}
return r;
}Execution results : adopt
Execution time :4 ms, In all C Defeated in submission 56.33% Users of
Memory consumption :5.4 MB, In all C Defeated in submission 71.08% Users of
Pass the test case :1032 / 1032
边栏推荐
- 【故障诊断】基于贝叶斯优化支持向量机的轴承故障诊断附matlab代码
- 28. Implement strStr()实现 strStr()
- Esxi 7.0 installation supports mellanox technologies mt26448 [connectx en 10gige, PCIe 2.0 5gt/s] driver, and supports the cheapest 10GB dual fiber network card
- mysql优化之索引及索引失效
- 数据库性能测试(mysql)
- 力扣——4. 寻找两个正序数组的中位数
- Use scanner to get multiple data types from the keyboard
- Find the original root
- mysql优化之show profile的使用及分析
- CONDA virtual environment envs directory is empty
猜你喜欢
随机推荐
带你搞透IO多路复用原理(select、poll和epoll)
Valid bracket sequence of "Niuke | daily question"
Force buckle - 3. Longest substring without repeated characters
Ruby on rails Code Execution Vulnerability (cve-2020-8163) technical analysis, research, judgment and protection
What are the aspects of performance testing? What are the classification and testing methods?
供应链的多目标协同决策
[image denoising] image denoising based on bicube interpolation and sparse representation matlab source code
Slice and array of go
『HarmonyOS』DevEco的下载安装与开发环境搭建
How does the national standard gb28181 protocol easygbs platform realize device video recording and set streaming IP?
Gdown Access denied:Cannot retrieve the public link of the file.
Which "digital currencies" can survive this winter? 2020-03-30
Heap sort
C language introduction practice (7): switch case calculation of days in the year (normal year / leap year calculation)
打开服务器上的 IncludeExceptionDetailInFaults (从 ServiceBehaviorAttribute 或从 &lt;serviceDebug&gt; 配置行为)以便将异常信息发送回
【图像隐藏】基于混合 DWT-HD-SVD 的数字图像水印方法技术附matlab代码
Deep learning - CV, CNN, RNN
堆排序(heap-sort)
@Constructorproperties annotation understanding and its corresponding usage
[image hiding] digital image watermarking method technology based on hybrid dwt-hd-svd with matlab code









