当前位置:网站首页>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;
}
边栏推荐
- El tree whether leaf node or not, the drop-down button is permanent
- Yuan universe also "real estate"? Multiple second-hand trading websites block metauniverse keywords
- Eight days of learning C language - while loop (embedded) (single chip microcomputer)
- Design and practice of kubernetes cluster and application monitoring scheme
- Openresty ngx Lua Execution stage
- The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
- Problem solving: attributeerror: 'nonetype' object has no attribute 'append‘
- SQL performance optimization skills
- 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?
- Acwing第 58 场周赛【完结】
猜你喜欢
Design of kindergarten real-time monitoring and control system
Design and practice of kubernetes cluster and application monitoring scheme
Character painting, I use characters to draw a Bing Dwen Dwen
Machine learning experiment report 1 - linear model, decision tree, neural network part
1.五层网络模型
Simple use of devtools
Asp+access campus network goods trading platform
Sqoop command
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
SQL injection exercise -- sqli Labs
随机推荐
Azkaban安装部署
Anchor free series network yolox source code line by line explanation four (a total of ten, ensure line by line explanation, after reading, you can change the network at will, not just as a participan
FBO and RBO disappeared in webgpu
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
el-select,el-option下拉选择框
qrcode:将文本生成二维码
Design and implementation of campus epidemic prevention and control system based on SSM
Scientific research: are women better than men?
Kbp206-asemi rectifier bridge kbp206
[micro service SCG] 33 usages of filters
Flume配置4——自定义MYSQLSource
Accuracy problem and solution of BigDecimal
2022/02/13
Pat grade a 1119 pre- and post order traversals (30 points)
Pat class a 1162 postfix expression
【LeetCode】222. The number of nodes of a complete binary tree (2 mistakes)
Avoid material "minefields"! Play with super high conversion rate
【微服务|SCG】Filters的33种用法
Sqoop command
Eight days of learning C language - while loop (embedded) (single chip microcomputer)