当前位置:网站首页>刷题《剑指Offer》day07
刷题《剑指Offer》day07
2022-07-31 08:11:00 【吃豆人编程】
题目来源:力扣《剑指Offer》第二版
完成时间:2022/07/29
17. 打印从1到最大的n位数
我的题解
class Solution {
public:
vector<int> printNumbers(int n) {
vector<int> result;
for(int i = 1;i < pow(10,n);i++) {
result.push_back(i);
}
return result;
}
};
18. 删除链表的节点
我的题解
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */
class Solution {
public:
ListNode* deleteNode(ListNode* head, int val) {
ListNode* head1 = new ListNode(-1);
head1->next = head;
ListNode* tmp = head1;
while(tmp->next){
if(tmp->next->val == val){
tmp->next = tmp->next->next;
break;
}
tmp = tmp->next;
}
return head1->next;
}
};
边栏推荐
- 循环结构--for循环
- 全国中职网络安全B模块之国赛题远程代码执行渗透测试 PHPstudy的后门漏洞分析
- sqlmap使用教程大全命令大全(图文)
- Cloud server deployment web project
- 会话技术之Coookie && Session详解
- 中软国际携手深开鸿发布(1+1) x N 战略,以数字化、智慧化改变人类生产和生活方式
- 【pytorch记录】pytorch的分布式 torch.distributed.launch 命令在做什么呢
- Doraemon teach you forwarded and redirect page
- 7/28-7/29 Expectation + thinking + suffix array + ST table
- ZCMU--1862: zbj的狼人杀
猜你喜欢
随机推荐
《如何戒掉坏习惯》读书笔记
【Unity】编辑器扩展-02-拓展Hierarchy视图
TypeError The view function did not return a valid response. The function either returned None 的解决
[MySQL exercises] Chapter 5 · SQL single table query
PHP中 比较 0、false、null,‘‘ “
如何在一台机器上(windows)安装两个MYSQL数据库
vscode输出中文乱码问题
Vulkan与OpenGL对比——Vulkan的全新渲染架构
SQLAlchemy使用教程
Vue项目通过node连接MySQL数据库并实现增删改查操作
[Yellow ah code] Introduction to MySQL - 3. I use select, the boss directly drives me to take the train home, and I still buy a station ticket
[MySQL exercises] Chapter 4 · Explore operators in MySQL with kiko
【pytorch记录】pytorch的分布式 torch.distributed.launch 命令在做什么呢
[Mini Program Project Development--Jingdong Mall] Custom Search Component of uni-app (Middle)--Search Suggestions
ScheduledExecutorService - 定时周期执行任务
R语言 第一部分
【小程序专栏】总结uniapp开发小程序的开发规范
Open Source | Commodity Recognition Recommender System
Install the deployment kubernetes KubeSphere management
重装系统后,hosts文件配置后不生效