当前位置:网站首页>刷题《剑指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;
}
};
边栏推荐
猜你喜欢

Open Source | Commodity Recognition Recommender System

蚂蚁核心科技产品亮相数字中国建设峰会 持续助力企业数字化转型

Flutter Paystack 所有选项实现
![[Cloud native] Introduction and use of Feign of microservices](/img/39/05cf7673155954c90e75a8a2eecd96.jpg)
[Cloud native] Introduction and use of Feign of microservices

【idea 报错】 无效的目标发行版:17 的解决参考

MUI获取相机权限

sqlmap使用教程大全命令大全(图文)
![[转载] Virtual Studio 让系统找到需要的头文件和库](/img/85/909c2ef52bbecb3faf7ed683fee65b.png)
[转载] Virtual Studio 让系统找到需要的头文件和库

SSM integration case study (detailed)

一文搞定代码中的命名
随机推荐
Vue项目通过node连接MySQL数据库并实现增删改查操作
SQLAlchemy使用教程
A, MySQL principle of master-slave replication
How to restore data using mysql binlog
Vscode: Project-tree plugin
Doraemon teach you forwarded and redirect page
【小程序项目开发-- 京东商城】uni-app之自定义搜索组件(下) -- 搜索历史
The Spark run on Yarn Spark application
MySQL 日期时间类型精确到毫秒
科目三:前方路口直行
【云原生与5G】微服务加持5G核心网
[Mini Program Project Development--Jingdong Mall] Custom Search Component of uni-app (Middle)--Search Suggestions
How on one machine (Windows) to install two MYSQL database
SSM框架讲解(史上最详细的文章)
Cloud server deployment web project
google搜索技巧——程序员推荐
功能强大的国产Api管理工具
Regarding "computing power", this article is worth reading
【小程序项目开发 -- 京东商城】uni-app 商品分类页面(下)
SQL 嵌套 N 层太长太难写怎么办?