当前位置:网站首页>刷题《剑指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;
}
};
边栏推荐
猜你喜欢
随机推荐
信息收集-DNS
How on one machine (Windows) to install two MYSQL database
How to restore data using mysql binlog
Open Source | Commodity Recognition Recommender System
New in Visual Studio: Low Priority Builds
【pytorch记录】pytorch的分布式 torch.distributed.launch 命令在做什么呢
控制文本保留几行,末尾省略
全国中职网络安全B模块之国赛题远程代码执行渗透测试 PHPstudy的后门漏洞分析
云服务器部署 Web 项目
TypeError The view function did not return a valid response. The function either returned None 的解决
期刊投递时的 Late News Submission 是什么
Unreal基础概念
Regarding "computing power", this article is worth reading
2019 NeurIPS | Graph Convolutional Policy Network for Goal-Directed Molecular Graph Generation
Linux redis6.2.6 configuration file
关于Error EPERM operation not permitted, mkdir...几种解决办法的比较
【idea 报错】 无效的目标发行版:17 的解决参考
48页智慧城市规划蓝图 解决方案
7/28-7/29 Expectation + thinking + suffix array + ST table
Ubuntu22.04安装mysql









