leetcode 738.Monotone Increasing Digits

idea 编译打包nacos2.0.3源码,生成可执行jar 包常见问题 阅读详情

Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits.

(Recall that an integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.)

Example 1:
Input: N = 10
Output: 9
Example 2:
Input: N = 1234
Output: 1234
Example 3:
Input: N = 332
Output: 299

题目给出一个数字N,让输出一个<=N小,而且要逐位升序(包括相等)的数字
图中example3,如果输出=N的数字,因为N中后面两位是降序的,所以要想升序,只能最大299

思路:
N如果是个位数,直接输出N就可以了

N的位数>=2时,类似31.Next Permutation的思路
31题因为数字是固定的,只能调换顺序,所以找到降序的位置,和降序后面的仅比它大的数字交换,然后降序后面的部分升序排列

此题因为不需要固定数字,同样也是找到降序的地方,降序后面的部分直接全部换成最大的9

**为了方便数字逐位操作,把int型数字转化成char数组
注意降序后面换成9的部分
比如332,检测到降序的index是i=2
这时候应该把index前面的一位 j 数字 -1. 变成322

因为输出的结果中不能有降序的数字,所以遇到降序仍然往前 -1
这时候j指向2,j的前面一位3仍然>2
再把j前面一位-1, 变成222
这时候从现在的j+1开始到后面全部变成9,即299
int j = i;
while (j >= 1 && num[j] < num[j - 1]) {

//1ms
    public int monotoneIncreasingDigits(int N) {
        if (N < 10) {
            return N;
        }
        
        char[] num = String.valueOf(N).toCharArray();
        int index = num.length;
        
        for (int i = 1; i < num.length; i++) {
            if (num[i - 1] > num[i]) {
                int j = i;
                while (j >= 1 && num[j] <  num[j - 1]) {
                    num[--j] --;
                }
                index = j + 1;
                break;
            }
        }
        
        for (int j = index; j < num.length; j ++) {
            num[j] = '9';
        }
        
        return Integer.parseInt(String.valueOf(num));
    }
windows10下 iperf3测试带宽 客户端输入:"iperf3.exe -u -c 服务器IP地址 -b 5g" //客户端给服务器发送udp数据包,最大带宽为5g。客户端输入:“iperf3.exe -c 服务器IP地址 -P 10“//表示客户端10路并行给服务器发送TCP包;上图可知:带宽是15Gbps(这里不知道为什么下面测试的UDP会比这里TCP慢 按道理UDP不可能比TCP慢的5.)3. 验证是否下载成功,在打开的窗口中输入“iperf3.exe -v”,会出现安装的版本,表示安装成功了。5. iperf3参数。 阅读详情

相关推荐

AGV舵轮选型实战:从核心参数到精准计算的完整指南

本文提供了一份详尽的AGV舵轮选型实战指南,强调从经验决策转向数据驱动。文章系统讲解了如何将工况需求转化为核心参数,并通过牵引力、扭矩、功率等关键计算步骤,指导工程师完成精准选型,避免因选型不当导致的运行故障与效率低下。

醉三国 511

Java实现 LeetCode 738 单调递增的数字(暴力)

738. 单调递增的数字 给定一个非负整数 N,找出小于或等于 N 的最大的整数,同时这个整数需要满足其各个位数上的数字是单调递增。 (当且仅当每个相邻位数上的数字 x 和 y 满足 x <= y 时,我们称这个整数是单调递增的。) 示例 1: 输入: N = 10 输出: 9 示例 2: 输入: N = 1234 输出: 1234 示例 3: 输入: N = 332 输出: 299 说明:...

南 墙 9993

逆向分析踩坑记:当Frida在x86模拟器上‘看不见’ARM的so文件时,我们该如何手动定位与验证?

本文探讨了在x86模拟器上使用Frida进行逆向分析时,无法检测到ARM架构so文件的解决方案。通过分析内存映射、Frida的视觉盲区及手动定位技术,提供了兼容层、混合调试和原生ARM环境三种实用方案,帮助逆向工程师突破工具限制,实现精准定位与验证。

weixin_27697385的博客 231

[leetcode] 738. Monotone Increasing Digits

Description Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits. (Recall that an integer has monotone increasing digits if and only ...

Learning from the mistakes 299

【Azure 架构师学习笔记】- Azure Private Endpoint

公有云的其中一个特点是默认允许公网访问, 这就对企业环境带来风险,也是很多年前企业对公有云抵触的其中一个原因,现在这类问题已经很少,因为有了很多技术来确保云上的资源被安全地访问。其中Private endpoint(PE)就起到了很重要的作用。云上的某个资源如VM会创建在特定的网络(VNet/Subnet)上, 而其他如Storage Account , Azure SQL等PaaS服务则没有。如果你需要用VM 来访问这些PaaS资源,VM 就会通过资源的公网IP 来访问。

MVP黄钊吉(發糞塗牆) 1797

全网最全医学图像数据汇总

本仓库汇总了多个领域的医学图像开源数据集,涵盖CT、MRI、超声、内窥镜、病理、多模态、PET、OCT以及皮肤镜等多种成像技术。每个数据集均详细列出了任务类型、部位、格式、数量及下载链接,旨在为医学图像研究者提供便捷的资源导航。⚠️:这些数据集仅适用于学术研究用途。

2401_83173765的博客 3331

738. Monotone Increasing Digits(贪心)

1.题目描述 Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits. (Recall that an integer has monotone increasing digits if and only if

stsfang 330

将点云坐标转换成世界坐标的demo

将点云坐标转换成世界坐标的demo

howard789的博客 2220

*Leetcode 738. Monotone Increasing Digits

https://leetcode.com/problems/monotone-increasing-digits/description/   这个难度的还是比较容易想的,找到最左边不合法的位置 后面都设置成9即可   需要从右向左找 因为有 3312这种case,第二个3更新之后 第一个3一样要更新。。 class Solution { public: int monoton...

Pilgrim 326

Retinanet训练自己的数据(2):模型准备

  在上一篇博客中,我们已经处理好了模型需要的数据集,下一步就是准备模型去训练数据。这里提醒一句,在制作数据时,最好将训练集和测试集人为分开。像Google tensorflow API,在制作数据时可以按比例自动生成,但是在上一篇文章中产生的数据(annotation.csv )其实都是用来训练的,如果你把自己的数据集全都转换了,那么恭喜你,最后你会发现没有数据集去测试了。   下面开始模型准...

mingyang_wang的博客 5887

YOLOv11改进 | Conv改进篇 | 含2种改进,引入DynamicConv替换普通Conv卷积下采样和C3k2_DynamicConv替换C3k2(来自CVPR2024)

本文提出了一种基于DynamicConv动态卷积优化的YOLOv11轻量化模型改进方案。通过引入多专家机制的动态卷积模块,在增加模型参数量的同时保持较低的计算复杂度(FLOPs),有效解决了低FLOPs模型在大规模预训练中的性能瓶颈问题。文章详细介绍了动态卷积的工作原理、核心代码实现,并提供了在YOLOv11中集成DynamicConv和C3k2_GhostModule_DynamicConv模块的完整教程,包括模块添加、配置文件修改和模型训练验证过程。实验结果表明,该方案在保持高效推理速度的同时显著提升了

Ai缝合怪、助力小伙伴高效发论文 549

[leetcode]738. Monotone Increasing Digits

[leetcode]738. Monotone Increasing Digits Analysis 放假回家效率果然打折—— [每天刷题并不难0.0] Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits...

weixin_32135877的博客 157

ESP32-C3蓝牙透传通信的BLE协议栈工程实践

蓝牙低功耗(BLE)透传是一种基于GATT服务模型的数据透明传输机制,其核心原理在于Peripheral设备通过广播建立连接,并在GATT Server层暴露可读写特征值实现双向数据通道。该技术具备低功耗、跨平台兼容性强、开发门槛适中等优势,广泛应用于智能硬件、工业传感器与嵌入式网关等场景。在实际工程中,透传稳定性高度依赖BLE协议栈的分层协同——Link Layer负责可靠连接建立,GATT Server则定义数据交互语义;而ESP32-C3的AT指令集正是对这两层能力的封装调度。本文聚焦BLE透传的关键

weixin_29859471的博客 132

LeetCode //C - 738. Monotone Increasing Digits

An integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y. Given an integer n, return *the largest number that is less than or equal to n with monotone increasing digits.*

Made in Code 1519

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Leetcode 738. Monotone Increasing Digits

Leetcode 738. Monotone Increasing Digits

u013898524的博客 794

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

LeetCode 738 monotone-increasing-digits

LeetCode 738 要求的这个数, 从前向后都是递增的(不小于) <= N中最大的 我们考虑332 这个case,因为要求最大,我们需要尽可能的保持高位, 最高位是3,这个不成立 最高位是2,那么后续我们都可以填写成最大的数。 再举个例子,2419, 最高位2,由于小于后面的4,可以保留 4由于大于1,没法保留,只能改成3, 一旦做了这个修改,后面的位数都是可以修改成9的。 总结一下,...

frankguodongchen的博客 154

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

LeetCode-738. Monotone Increasing Digits

题目 Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits. (Recall that an integer has monotone increasing digits if and only if eac...

Flower的博客 169

LeetCode738. Monotone Increasing Digits

【代码】LeetCode738. Monotone Increasing Digits。

叶卡捷琳堡的博客 804

Leetcode算法学习日志-738 Monotone Increasing Digits

Leetcode 738 Monotone Increasing Digits 题目原文 Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits. (Recall that an integer has

Zarlove的博客 514

[LeetCode] 738. Monotone Increasing Digits

Given a non-negative integerN, find the largest number that is less than or equal toNwith monotone increasing digits. (Recall that an integer hasmonotone increasing digitsif and only if eac...

a0712104790的博客 101

【Leetcode】738. Monotone Increasing Digits

题目地址: https://leetcode.com/problems/monotone-increasing-digits/ 给定一个非负正整数nnn,求一个这样的非负整数xxx,xxx从左到右读是单调上升的(不要求严格上升),x≤nx\le nx≤n并且xxx是满足这两个条件的最大整数。 先将nnn转为字符串sss,然后从左向右扫描。如果一路都是递增的,那么直接返回nnn自己就好了。否则考虑如何求。我们找到第一个s[i]>s[j]s[i]>s[j]s[i]>s[j]的位置,这里下降了,

数学、算法爱好者的博客 239

LeetCode刷题 | 738. Monotone Increasing Digits

Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits. (Recall that an integer has monotone increasing digits if and only if each

u012737193的博客 541

LeetCode—738. Monotone Increasing Digits

LeetCode题目描述 Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits.

junex的博客 419

leetcode 738. Monotone Increasing Digits

Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits. (Recall that an integer has monotone increasing digits if and only if each pair...

突破吧!次元壁 281
上一篇: leetcode 714. Best Time to Buy and Sell Stock with Transaction Fee
下一篇: leetcode 56. Merge Intervals
蓝羽飞鸟
博客等级 码龄8年 1万+粉丝 727原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蓝羽飞鸟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址