当前位置:网站首页>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
边栏推荐
- The creation of "harmonyos" project and the use of virtual machines
- Address resolution ARP Protocol
- Deep learning - CV, CNN, RNN
- Liberg avenue to Jane series
- "Niuke | daily question" inverse Polish expression
- Do you think you are a reliable test / development programmer? "Back to the pot"? Surface and reality
- Tiktok web s_ v_ web_ Analysis and implementation of ID parameter generation
- 28. Implement strStr()实现 strStr()
- 日志轮转logrotate
- 『牛客|每日一题』点击消除
猜你喜欢

UIToolkit中显示汉字

Sorting problem: bubble sort, select sort, insert sort

TCP protocol -- message format, connection establishment, reliable transmission, congestion control

快速排序(quick-sort)

【图像隐藏】基于混合 DWT-HD-SVD 的数字图像水印方法技术附matlab代码

Press in and pop-up sequence of "Niuke | daily question" stack

"Niuke | daily question" inverse Polish expression
![[C language] file operation](/img/19/5bfcbc0dc63d68f10155e16d99581c.png)
[C language] file operation

【Star项目】小帽飞机大战(三)

Children's programming electronic society graphical programming level examination scratch level 1 real problem analysis (multiple choice) June 2022
随机推荐
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
Integrated design of signal processing systems - Design of solver functions (continuous and discrete time systems)
『牛客|每日一题』逆波兰表达式
Vision Transformer 必读系列之图像分类综述
Merge_sort
Nuxt configuration topic switching
Slice and array of go
"Harmonyos" explore harmonyos applications
日志轮转logrotate
Torth file read vulnerability (cnvd-2020-27769)
『牛客|每日一题』模板栈
09 eth smart contract
vulnhub Lampião: 1
Upgrade appium automation framework to the latest 2.0
[Web3 series development tutorial - create your first NFT (4)] what can NFTs bring to you
Regular expressions and calling related functions in C language
"Niuke | daily question" template stack
【C语言】文件操作
Multi target detection
【C语言】通讯录动态版和文件版