当前位置:网站首页>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;
}
边栏推荐
- 有个疑问 flink sql cdc 的话可以设置并行度么, 并行度大于1会有顺序问题吧?
- Returns the lowest common ancestor of two nodes in a binary tree
- Spark SQL learning bullet 2
- Blue bridge - maximum common divisor and minimum common multiple
- Vb+access hotel service management system
- 端口,域名,协议。
- this+闭包+作用域 面试题
- Medusa installation and simple use
- Mongodb common commands
- Ask, does this ADB MySQL support sqlserver?
猜你喜欢

1. Five layer network model

【LeetCode】501. Mode in binary search tree (2 wrong questions)

College Students' innovation project management system

Spoon inserts and updates the Oracle database, and some prompts are inserted with errors. Assertion botch: negative time

Share the newly released web application development framework based on blazor Technology

Bumblebee: build, deliver, and run ebpf programs smoothly like silk

Azkaban installation and deployment

Devtools的简单使用

Elk log analysis system

Vb+access hotel service management system
随机推荐
Pytest (5) - assertion
Utilisation simple de devtools
[micro service SCG] 33 usages of filters
Design of KTV intelligent dimming system based on MCU
Bumblebee: build, deliver, and run ebpf programs smoothly like silk
this+闭包+作用域 面试题
Why is this an undefined behavior- Why is this an undefined behavior?
qrcode:将文本生成二维码
Design and practice of kubernetes cluster and application monitoring scheme
Character painting, I use characters to draw a Bing Dwen Dwen
Single box check box
Design and practice of kubernetes cluster and application monitoring scheme
Kbp206-asemi rectifier bridge kbp206
Accuracy problem and solution of BigDecimal
[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)
el-select,el-option下拉选择框
openresty ngx_ Lua variable operation
Design and implementation of community hospital information system
Ask, does this ADB MySQL support sqlserver?
1.五层网络模型