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 6b38053

Browse files
committed
Update 0738.单调递增的数字,添加C#
1 parent 98827c1 commit 6b38053

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎problems/0738.单调递增的数字.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,30 @@ impl Solution {
392392
}
393393
}
394394
```
395+
### C#
396+
```csharp
397+
public class Solution
398+
{
399+
public int MonotoneIncreasingDigits(int n)
400+
{
401+
char[] s = n.ToString().ToCharArray();
402+
int flag = s.Length;
403+
for (int i = s.Length - 1; i > 0; i--)
404+
{
405+
if (s[i - 1] > s[i])
406+
{
407+
flag = i;
408+
s[i - 1]--;
409+
}
410+
}
411+
for (int i = flag; i < s.Length; i++)
412+
{
413+
s[i] = '9';
414+
}
415+
return int.Parse(new string(s));
416+
}
417+
}
418+
```
395419

396420
<p align="center">
397421
<a href="https://programmercarl.com/other/kstar.html" target="_blank">

0 commit comments

Comments
(0)

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