leetcode738
public class Solution
{
public int MonotoneIncreasingDigits(int N)
{
var num = N.ToString();
var len = num.Length;
if (len == )
{
return N;
}
int[] X = new int[len];
for (int i = ; i < len; i++)
{
X[i] = Convert.ToInt32(num[i].ToString());
}
var change = true;
while (change)
{
var change_count = ;
for (int i = ; i < len; i++)
{
var n1 = X[i - ];
var n2 = X[i];
if (n1 > n2)
{
change_count++;
X[i - ] -= ;
for (int j = i; j < len; j++)
{
X[j] = ;
}
change = true;
break;
}
}
if (change_count == )
{
change = false;
}
} var temp = "";
for (int i = ; i < len; i++)
{
temp += X[i];
}
var result = Convert.ToInt32(temp);
return result;
}
}
leetcode738的更多相关文章
- [Swift]LeetCode738. 单调递增的数字 | Monotone Increasing Digits
Given a non-negative integer N, find the largest number that is less than or equal to Nwith monotone ...
随机推荐
- 导出csv文件,导出axlsx文件。gem 'Axlsx-Rails' (470🌟);导入csv文件。
汇出 CSV 档案 需求:后台可以汇出报名资料 有时候后台功能做再多,也不如 Microsoft Excel 或 Apple Numbers 试算表软件提供的分析功能,这时候如果有汇出功能,就可以很方 ...
- linux挂载windows共享文件夹出错,提示mount error(13): Permission denied
完整的可以工作的命令行: mount -v -t cifs -o username=clouder,password=123456,iocharset=utf8,sec=ntlm //172.28.1 ...
- 《Java程序设计》十四次作业
<Java程序设计>十四次作业实验总结 1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结与数据库相关内容. 3. 代码量统计 周次 总代码量 新增代码量 总文件数 新增 ...
- PHPCMS v9 二次开发_验证码结合Session开发
本文主要讲解了在V9中使用v9自带验证码并且需要使用session的情况下,多种问题的解决.:).如有问题或者更好的解决办法,希望不吝赐教. 1.前端调用验证码 pc_base::load_sys_c ...
- timer Compliant Controller project (1)--Product introduction meeting
Last week ,I lead the meeting for new project. i'm very excited. The meeting is divided into the fo ...
- Oracle(一)安装
一.到官网或者哪里去下载Oracle,我下的是winX64的11g版本 官网:https://www.oracle.com/technetwork/database/enterprise-editio ...
- How to convert a QString to unicode object in python 2?
How to convert a QString to unicode object in python 2? I had this problem to solve, and I tried to ...
- CtaAlgo vs PyAlgoTrade
转自知乎:https://zhuanlan.zhihu.com/p/21971854 在Python量化领域,PyAlgoTrade和zipline并列两大策略回测框架的先驱,其中PyAlgoTrad ...
- 走在linux 的路上
终于现在不看鸟哥的私房菜基础篇了,以后再慢慢看,像我这种初学者,感觉还是不太适合看鸟哥的私房菜. 于是从图书馆借了本书继续学习我的linux. 这样看着linux容易多了,进而熟悉了几个命令:ls c ...
- B树、B-树、B+树、B*树都是什么
B树.B-树.B+树.B*树都是什么 B树 即二叉搜索树: 1.所有非叶子结点至多拥有两个儿子(Left和Right): 2.所有结点存储一个关键字: 3.非叶子结点的左指针指向小于其关键字的子树,右 ...