当前位置:网站首页>LeetCode 234. Palindrome linked list
LeetCode 234. Palindrome linked list
2022-07-05 03:00:00 【Abby's daily life】
https://leetcode-cn.com/problems/palindrome-linked-list/
Ideas
- Linked list element value storage list
- Double pointer (0 Start , Start at the end ) Determine if the values are equal
/** Linked list values are added to the set Double pointer */
public boolean isPalindrome(ListNode head) {
List<Integer> list = new ArrayList<>();
ListNode curr = head;
while (curr != null) {
list.add(curr.val);
curr = curr.next;
}
int first = 0;
int last = list.size() - 1;
while (first < last) {
if (list.get(first) != list.get(last)) {
return false;
}
first++;
last--;
}
return true;
}
边栏推荐
- 【LeetCode】501. Mode in binary search tree (2 wrong questions)
- Eight days of learning C language - while loop (embedded) (single chip microcomputer)
- Sqoop安装
- [daily problem insight] Li Kou - the 280th weekly match (I really didn't know it could be so simple to solve other people's problems)
- Privatization lightweight continuous integration deployment scheme -- 01 environment configuration (Part 1)
- [200 opencv routines] 99 Modified alpha mean filter
- Flume配置4——自定义MYSQLSource
- ELK日志分析系统
- Returns the lowest common ancestor of two nodes in a binary tree
- SQL performance optimization skills
猜你喜欢
Bumblebee: build, deliver, and run ebpf programs smoothly like silk
Azkaban overview
Pytest (4) - test case execution sequence
Pat grade a 1119 pre- and post order traversals (30 points)
openresty ngx_lua执行阶段
2021 Li Hongyi machine learning (3): what if neural network training fails
Zabbix
Flume配置4——自定义MYSQLSource
Elk log analysis system
ELK日志分析系统
随机推荐
Design and implementation of campus epidemic prevention and control system based on SSM
ELK日志分析系统
Bumblebee: build, deliver, and run ebpf programs smoothly like silk
Kbp206-asemi rectifier bridge kbp206
GFS distributed file system
Jd.com 2: how to prevent oversold in the deduction process of commodity inventory?
Design of KTV intelligent dimming system based on MCU
Sqoop installation
Design and practice of kubernetes cluster and application monitoring scheme
平台入驻与独立部署优缺点对比
Design of kindergarten real-time monitoring and control system
1. Five layer network model
Yuan universe also "real estate"? Multiple second-hand trading websites block metauniverse keywords
[200 opencv routines] 99 Modified alpha mean filter
Marubeni Baidu applet detailed configuration tutorial, approved.
ELFK部署
Moco V2 literature research [self supervised learning]
【LeetCode】111. Minimum depth of binary tree (2 brushes of wrong questions)
100 basic multiple choice questions of C language (with answers) 04
Hot knowledge of multithreading (I): introduction to ThreadLocal and underlying principles