当前位置:网站首页>3. Print the linked list in reverse order with the array
3. Print the linked list in reverse order with the array
2022-07-28 10:16:00 【[email protected]】
In fact, the first thing I thought of was using stacks , Because the stack is “ First in, then out ”
class Solution {
public int[] reversePrint(ListNode head) {
LinkedList<Integer> stack = new LinkedList<Integer>();// Define stack
while(head != null){
stack.addLast(head.val);
head = head.next;
}
int[] array = new int[stack.size()];
for(int i = 0;i <array.length;i++){
array[i] = stack.removeLast();
}
return array;
}
}
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207280958224800.html
边栏推荐
- select如果不加order by子句,返回结果的顺序是不可靠的
- Being on duty less than 8 hours a day and being dismissed? Tencent's former employees recovered 13million overtime pay, etc., and the court won a compensation of 90000 in the final judgment
- 巧用ngx_lua做流量分组
- 安装gmp
- What are the advantages of MRO purchasing website for industrial products? One article will help you understand
- 网易笔试之不要二——欧式距离的典型应用
- Redis面试题必知必会
- Arthas tutorial
- Elk real time log analysis platform
- Description of landingsite electronic label quppa firmware entering DFU status
猜你喜欢

LSA and optimization of OSPF

Skillfully use NGX_ Lua makes traffic grouping

What kind of knowledge payment system functions are more conducive to the development of the platform and lecturers?

B2B e-commerce website scheme for building materials industry: enable the transformation and upgrading of building materials enterprises to achieve cost reduction and efficiency improvement

Thinking and summary of technical personnel | R & D Efficiency

Digital transformation scheme of real estate: all-round digital intelligence system operation, helping real estate enterprises improve the effectiveness of management and control

2022 uni app parsing token standard - use jsrsasign - climb the pit
![[esp32][esp idf][lvgl7.9] failed to compile with OLED IIC](/img/16/e5aa43df6ef9bdbc173fa547c85559.png)
[esp32][esp idf][lvgl7.9] failed to compile with OLED IIC

On July 13, 2021, we collapsed like this

什么样的知识付费系统功能,更有利于平台与讲师发展?
随机推荐
Kubernetes
10、链表中倒数第k个节点
数据库mysql基础
21. 合并两个有序链表
JWT login authentication + token automatic renewal scheme, well written!
Elk real time log analysis platform
Flink - checkpoint Failure reason: Not all required tasks are currently running
Vulnerability analysis hevd-0x8.integeroverflow[win7x86]
OSPF expansion configuration, routing principles, anti ring and re release
What are the highlights of B2B2C system? How to help jewelry enterprises build an omni channel multi merchant mall management system
centos7下安装mysql,网上文章都不太准
2022-uni-app解析token标准的方式-使用jsrsasign-爬坑过了
Summary of key points of bank entry examination
matlab特征点提取--记录自用
[cloud based co creation] Huawei cloud: metastudio digital content production line, which seamlessly integrates the virtual world with the real world
ES(8.1)认证题目
UEditor V1.4.3控制文件压缩
Tencent technical experts: decrypt the 100 million user products wechat, QQ, King glory... Comprehensively practice on the cloud!
19. 删除链表的倒数第 N 个结点
QT | some summaries of signals and slots