leetcode 之Plus One(9)
2024-10-19 01:32:43
这题需要注意的是最后的进位
vector<int> plusOne(vector<int>& nums,int num)
{
add(nums, num);
}
void add(vector<int> &nums, int num)
{
int c = num;
for (auto it = nums.rbegin(); it != nums.rend(); it++)
{
*it += c;
*it = *it / ;
c = *it % ;
}
if (c > )
nums.insert(nums.begin(), );
}
最新文章
- Bootstrap Affix(附加导航(Affix)插件的用法)
- Winpcap安装,Cannot open include file &#39;pcap.h&#39;
- lua中常量的实现及表的深拷贝实现
- 免费素材下载:iOS 8 矢量 UI 素材套件
- springmvc+spring+mybatis分页查询实例版本3,添加条件检索
- Android Studio 学习 - 基本控件的使用;Intent初学
- PostgreSQL的 initdb 源代码分析之十三
- 隐藏win7盘符
- sql知识
- Hadoop 安装(1) CENTOS 安装与配置
- WPF之TabControl控件用法
- cookie记忆换肤功能实战Demo
- bzoj 4822: [Cqoi2017]老C的任务
- Monkey 生成报告方法
- 洛谷 4115 Qtree4——链分治
- MyBatis中resultType和resultMap的区别
- delphi中的 IntToHex()
- STM32F4的sct文件理解
- Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener. ...nested exception is java.lang.NoSuchMethodError:
- pgAdmin4 汉化
热门文章
- [SDOI2013]淘金 数位DP
- BZOJ1014:[JSOI2008]火星人prefix——题解
- HDOJ.1009 FatMouse' Trade (贪心)
- bzoj3810: [Coci2015]Stanovi(记忆化搜索)
- Human life FZU - 2295 最大权闭合子图(第一次遇到被教育了)
- [LeetCode] 6. ZigZag Conversion ☆☆☆
- RabbitMQ的使用总结
- 51Nod 1133 不重叠的线段 | 典型贪心
- jsp 内置对象二
- 【usaco-Earthquake, 2001 Open】 0-1分数规划 &; 最优比率生成树