当前位置:网站首页>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】404. Sum of left leaves (2 brushes of wrong questions)
- Avoid material "minefields"! Play with super high conversion rate
- The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
- Blue bridge - maximum common divisor and minimum common multiple
- Usage scenarios and solutions of ledger sharing
- El select, El option drop-down selection box
- Character painting, I use characters to draw a Bing Dwen Dwen
- Sqoop安装
- Design of KTV intelligent dimming system based on MCU
- Devtools的简单使用
猜你喜欢

Azkaban overview

This + closure + scope interview question

2021 Li Hongyi machine learning (3): what if neural network training fails

Anchor free series network yolox source code line by line explanation Part 2 (a total of 10, ensure to explain line by line, after reading, you can change the network at will, not just as a participan

VM in-depth learning (XXV) -class file overview

The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
![Hmi-30- [motion mode] the module on the right side of the instrument starts to write](/img/6b/09bb8fd95b707a459534eaeb72eb59.jpg)
Hmi-30- [motion mode] the module on the right side of the instrument starts to write
![ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience](/img/22/08617736a8b943bc9c254aac60c8cb.jpg)
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience

Vb+access hotel service management system

Pytest (4) - test case execution sequence
随机推荐
VM in-depth learning (XXV) -class file overview
IPv6 experiment
There is a question about whether the parallelism can be set for Flink SQL CDC. If the parallelism is greater than 1, will there be a sequence problem?
The phenomenology of crypto world: Pioneer entropy
Hmi-32- [motion mode] add light panel and basic information column
Utilisation simple de devtools
Anchor free series network yolox source code line by line explanation Part 2 (a total of 10, ensure to explain line by line, after reading, you can change the network at will, not just as a participan
openresty ngx_lua执行阶段
Avoid material "minefields"! Play with super high conversion rate
Tiny series rendering tutorial
平台入驻与独立部署优缺点对比
TCP security of network security foundation
Voice chip wt2003h4 B008 single chip to realize the quick design of intelligent doorbell scheme
Zabbix
d3js小记
8. Commodity management - commodity classification
Pytest (4) - test case execution sequence
Devtools的簡單使用
低度酒赛道进入洗牌期,新品牌如何破局三大难题?
El tree whether leaf node or not, the drop-down button is permanent