Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb472433

Browse files
committed
Reverse Integer solution
1 parent92658cd commitb472433

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎typescript/7-Reverse-Integer.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
functionreverse(x:number):number{
2+
letint:number=Math.abs(x)
3+
letresult:number=0
4+
while(int>0){
5+
letnum:number=int%10
6+
int=Math.floor(int/10)
7+
result*=10
8+
result+=num
9+
}
10+
11+
if(result>Math.pow(2,31))return0
12+
returnresult*Math.sign(x)
13+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp