c# Solution


  • 0
    T

    public class Solution {
    public int MonotoneIncreasingDigits(int N) {
    char[] n = N.ToString().ToCharArray();
    int mark =n.Length;
    for(int i=n.Length-1;i>=1;i--)
    {
    if(n[i]<n[i-1])
    {
    mark = i;
    n[i-1]--;
    }
    }
    Console.WriteLine(mark);
    for(int i=mark;i<n.Length;i++)
    {
    n[i]='9';
    }
    return Convert.ToInt32(new String(n));
    }
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.