当前位置:网站首页>[Jianzhi offer simple] Jianzhi offer 06 Print linked list from end to end
[Jianzhi offer simple] Jianzhi offer 06 Print linked list from end to end
2022-06-12 21:52:00 【Caicai 2022】
subject
Code
Execution time :116 ms, In all Python3 Defeated in submission 12.70% Users of
Memory consumption :25.8 MB, In all Python3 Defeated in submission 10.26% Users of
Pass the test case :24 / 24
class Solution:
def reversePrint(self, head: ListNode) -> List[int]:
return self.reversePrint(head.next) + [head.val] if head else []
【 Method 2】
Execution time :40 ms, In all Python3 Defeated in submission 67.22% Users of
Memory consumption :16.7 MB, In all Python3 Defeated in submission 29.75% Users of
Pass the test case :24 / 24
class Solution:
def reversePrint(self, head: ListNode) -> List[int]:
ans=[]
while head:
ans.append(head.val)
head=head.next
return ans[::-1]
边栏推荐
- Limit of advanced mathematics
- Semester summary of freshman year
- 有向图深拷贝
- How to ensure thread safety?
- MySql主从复制
- SQL tuning guide notes 8:optimizer access paths
- Lambda expression and flow optimization code
- What is embedded
- Logstash timestamp converted to UNIX nanosecond nano second time
- SQL tuning guide notes 11:histograms
猜你喜欢

SQL tuning guide notes 14:managing extended statistics

Ansible基础和常用模块(一)

SQL tuning guide notes 8:optimizer access paths

Kdd2022 | graphmae: self supervised mask map self encoder

Build a highly available database

JVisualVM初步使用

“Oracle数据库并行执行”技术白皮书读书笔记

SQL tuning guide notes 10:optimizer statistics concepts

Ansible PlayBook et ansible roles (3)

Icml2022 | galaxy: active learning of polarization map
随机推荐
drf 接收嵌套数据并创建对象, 解决:drf NOT NULL constraint failed
六月集训(第10天) —— 位运算
Compiling process of OpenSSL and libevent on PC
How to ensure thread safety?
selenium操作元素遇到的异常
多线程模型下的生产者消费者模式
[target detection] |dive detector into box for object detection new training method based on fcos
Turing prize winner: what should I pay attention to if I want to succeed in my academic career?
Data batch writing
My struggle: my years in foreign enterprises (1)
Ansible summary (VI)
同花顺能开户吗,在APP上可以直接开通券商安全吗 ,证券开户怎么开户流程
Thread safe level
孙老师版本JDBC(2022年6月12日21:34:25)
CVPR 2022 | 应对噪声标签,西安大略大学、字节跳动等提出对比正则化方法
June training (day 11) - matrix
[leetcode] 573 complex multiplication (conversion between characters and numbers)
(4) Pyqt designs and implements the [factory production management system] order page - add, delete, modify and query (including source code analysis)
Xingda easy control modbustcp to profibusdp
[QNX hypervisor 2.2 user manual] 4.4 build host