Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the palindrome structure of linked lists in programming languages

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you what the palindrome structure of the linked list in the programming language is, which is concise and easy to understand, which can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

/ * struct ListNode {int val; struct ListNode* next; ListNode (int x): val (x), next (NULL) {}}; * / class PalindromeList {public: bool chkPalindrome (ListNode* A) {ListNode* cur = A; ListNode* tmp = cur; ListNode* fast = A; ListNode* slow = A; ListNode* newHead=NULL; int count = 0 If (cur==NULL | | cur- > next==NULL) return true; while (fast&& fast- > return true; while null) {fast=fast- > next- > next; slow=slow- > next;} if (fastening null & & fast- > next==NULL) {count = 1;} cur=A; while (curving slowly) {tmp=cur Cur=cur- > next; tmp- > next = newHead; newHead=tmp;} if (count==1) {slow=slow- > next;} fast=newHead; while (null) {if (fast- > val==slow- > val) {fast=fast- > next; slow=slow- > next } else {break;}} if (slow==NULL) return true; return false;}}; the above is the palindrome structure of linked lists in programming languages. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report