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

Commit e0d0ca2

Browse files
Compute Decimal Representation
1 parent 1d3dd98 commit e0d0ca2

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Link: https://leetcode.com/problems/compute-decimal-representation/
2+
Language: C#
3+
4+
5+
6+
7+
8+
9+
public class Solution {
10+
public int[] DecimalRepresentation(int n)
11+
{
12+
var list = new List<int>();
13+
int c = 1;
14+
15+
while (n > 0)
16+
{
17+
int i = n % 10;
18+
19+
if (i != 0)
20+
list.Add(i * c);
21+
22+
c *= 10;
23+
n /= 10;
24+
}
25+
26+
list.Reverse();
27+
28+
return list.ToArray();
29+
}
30+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /