LeetCode234. 回文链表(java)

BUSCO评估基因组的完整性 因为数据库收集的时候找的就是在不同的物种间都是单拷贝的基因,所以说在评估的物种里面应该也是单拷贝的状态才对。基因组层面评估:先去基因组上预测这些基因,再去做评估,如果说给他是一个注释好的基因集,这个时候提供的是一个蛋白集合,它就直接是去进行同源搜索,再去评估,看BUSCO数据库里面的这些单拷贝基因有或者无;首先,tblastn也是同源搜索,同源搜索之后,去对转录本进行读码框预测,预测完的结果还是去进行hmmsearch的搜索(hmmsearch是做蛋白质结构域搜索的),最终拿到BUSCO评估结果。 阅读详情

题目:

请判断一个链表是否为回文链表。

示例:
在这里插入图片描述
代码:

  • 解法一
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
    public boolean isPalindrome(ListNode head) {
        if(head==null||head.next==null){
            return true;
        }
        ListNode mid=middleNode(head);
        ListNode root=reversal(mid);
        ListNode p1=head;
        ListNode p2=root;
        while(p2!=null&&p1.val==p2.val){
                p1=p1.next;
                p2=p2.next;
        }
        return p2==null?true:false;
    }
    private ListNode middleNode(ListNode head){	//寻找中心元素
        ListNode slow=head;
        ListNode fast=head.next;
        while(fast!=null&&fast.next!=null){
            slow=slow.next;
            fast=fast.next.next;
        }
        return slow.next;
    }
    //迭代实现
    private ListNode reversal(ListNode head){
        ListNode root=new ListNode(0);
        ListNode cur=root;
        while(head!=null){
            cur=head;
            head=head.next;
            cur.next=null;
            cur.next=root.next;
            root.next=cur;
        }
        return root.next;
    }
}
  • 解法二
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
    public boolean isPalindrome(ListNode head) {
        if(head==null||head.next==null){
            return true;
        }
        ListNode mid=middleNode(head);
        ListNode root=reversal(mid);
        ListNode p1=head;
        ListNode p2=root;
        while(p2!=null&&p1.val==p2.val){
                p1=p1.next;
                p2=p2.next;
        }
        return p2==null?true:false;
    }
    private ListNode middleNode(ListNode head){
        ListNode slow=head;
        ListNode fast=head.next;
        while(fast!=null&&fast.next!=null){
            slow=slow.next;
            fast=fast.next.next;
        }
        return slow.next;
    }
    //迭代实现
    private ListNode reversal(ListNode head){
        if(head==null||head.next==null){
            return head;
        }
        ListNode h=reversal(head.next);
        head.next.next=head;
        head.next=null;
        return h;
    }
}
  • 别人的代码
 /**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
    public boolean isPalindrome(ListNode head) {
        if(head==null||head.next==null){
            return true;
        }
        if(head.next.next==null){
            return head.val == head.next.val;
        }
        ListNode slow = head;
        ListNode fast = head.next;
        
        while(fast.next!=null){
            if(slow.val == fast.next.val){
                if(fast.next.next!=null){
                    return false;
                }
                fast.next = null;
                slow = slow.next;
                fast = slow.next;
                if(fast==null || slow.val == fast.val){
                    return true;
                }
            }else{
                fast = fast.next;
            }
        }
        return false;
}
}

抖音无水印视频爬虫实战:从抓包分析到批量下载指定用户作品 抖音作为当前最受欢迎的短视频平台,拥有海量的优质内容。很多用户希望备份自己或他人的作品,但抖音官方并未提供批量下载功能,且直接下载的视频带有平台水印。本文将带领大家从零开始,通过抓包分析、设备模拟、请求签名等核心技术,实现一个完整的抖音无水印视频爬虫系统。本文仅供技术学习和个人备份使用,请勿将爬取的内容用于商业用途或侵犯他人版权,爬取频率请控制合理范围内。目录一、前言二、技术栈概览三、准备工作3.1 环境搭建3.2 抓包分析步骤3.3 关键API发现四、核心技术解密4.1 X-Gorgon签名算法。 阅读详情

相关推荐

STM32F4+FreeRTOS实战:手把手教你移植LWIP2.1.2(含LAN8720配置避坑指南)

本文提供了一份详尽的实战指南,手把手教你如何在STM32F4平台结合FreeRTOS实时操作系统,成功移植轻量级TCP/IP协议栈LWIP 2.1.2。文章重点剖析了硬件驱动层LAN8720 PHY芯片的配置要点与常见“坑点”,并深入讲解了LWIP与FreeRTOS的深度整合、关键配置及稳定性优化策略,旨在帮助开发者构建稳定可靠的产品级嵌入式网络功能。

ik678901234的博客 1065

LeeCode234回文链表(Java)(快慢指针,边遍历边反转)

题目链接:LeeCode234回文链表 题目描述: 拿到这道题首先想到的是找中间节点,所以肯定是用快慢指针,然后应该把前面或者后面倒叙再去比。 就想到反转链表这个题,进阶要求说是空间复杂度O(1)所以不能用栈,于是重新想了一下反转链表的做法,这里也是看了一个大神的思路,自己说实话也是半天没绕过来,取自leetcode题解某大神的图,设置两个指针一边遍历一边将指针反过来,于是反转链表的写法就如下 /** * Definition for singly-linked list. * public clas

weixin_43590593的博客 188

Python自动化批量识别化学分子结构——从图片到SMILES/SDF的实战指南

本文提供了使用Python自动化批量识别化学分子结构图片的实战指南。详细对比了基于Molvec API的在线快速方案与本地部署OSRA工具的两种路径,包含完整的代码示例、环境配置及优化技巧,帮助化学研究者高效地将图片批量转换为SMILES或SDF格式,显著提升数据处理效率。

apple5的专栏 947

LeetCode -234 - 回文链表 - Java - 三种解法

文章目录这题并不难,但是解法多样,所以作者觉得有必要写写!题目解法一(快慢指针 + 反转)代码附图解法二 - 通过将链表节点的val值 存入 顺序表/数组 中, 通过数组下标进行对比。代码附图解法三 - 递归代码附图 这题并不难,但是解法多样,所以作者觉得有必要写写! 题目 那上面例子来说: 就是链表的val值, 从左往右看(1,2,2,1)和 从右往左看(1,2,2,1),都是一样的,就返回true , 否则返回 false。   解法一(快慢指针 + 反转) 先使用快慢指针,得到中间节点,

DarkAndGrey的博客 1248

LAMMPS实操系列(一): 大量FCC-CoCrCuFeNi高熵合金建模与最稳定结构筛选

高熵合金(High-entropy alloys,HEA),是由五种或五种以上等量或大约等量金属形成的合金。由于高熵合金可能具有许多优秀的物理化学性质,因此在材料科学领域受到广泛关注

Ceshigo_CD的博客 3259

高通蓝牙学习-- 关于Android 蓝牙的介绍

本文详细介绍了AOSP蓝牙架构及高通QCA芯片的蓝牙功能实现方案。主要内容包括:1)AOSP蓝牙架构在不同Android版本中的层次结构,重点分析BTHIDL层和libbt-vendor关键组件;2)QCA芯片的引导流程说明;3)两种获取libbt-vendor源码的方式(Google官方源和国内镜像源);4)针对QCA6595/6696/66x8/67x7芯片的具体实现方案,包括固件文件定义、厂商事件处理和补丁下载流程;5)蓝牙调试方法,包括logcat日志分析、HSU和Ellisys硬件跟踪技术。文章为

专业开发者的博客,一个从事Android WiFi和蓝牙的工程师 496

Java 算法篇-链表的经典算法:判断回文链表、判断环链表与寻找环入口节点(“龟兔赛跑“算法实现)

判断回文链表:先找到链表中的中间节点,例如链表 1 -> 2 -> 3 -> 2 -> 1 -> null ,需要先找节点值为:3 的节点,可以用快慢指针来实现找中间节点。然后将该节点后面的链表( 3 -> 2 -> 1 -> null )进行反转,可以用递归来实现反转的链表,得 1 -> 2 -> 3 -> null 。接着,用旧链表进行与反转后的链表遍历比较,若出现不相同值的节点,则判断该链表不是回文链表;若遍历完都没有返回 false ,则判断该链表为回文链表。解释为什么第一次相遇后,兔、龟每一次都走

小扳手 3576

【人工智能】Open WebUI 安装指南 ( 基于Docker下载和使用Open WebUI 、通过本地运行项目源码进行搭建Open WebUI)

Open WebUI 是一个可扩展、功能丰富且用户友好的自托管 WebUI,旨在完全离线操作。它支持各种 LLM 运行程序,包括 Ollama 和 OpenAI 兼容的 API。社区:https://openwebui.com/

奶爸的编程之路,也就一周冷个三天 2万+

【LeetCode力扣】234 快慢指针 | 反转链表 | 还原链表

234. 回文链表 - 力扣(LeetCode)判断回文,就是判断是否是对称的。有些朋友对于数组的回文判断非常熟悉,但是对链表的回文判断可能就无从下手了,其实都一样的。有一种非常简单的方式就是将链表转化成数组,然后就是判断该数组是否回文就可以了,这种方式统称暴力破解法,简单粗暴。下面就来先带着大家看一下这道题的暴力破解法。

Hacynn的博客 1497

告别调参难!YOLO超参数优化指南(网格搜索+贝叶斯优化实战)

YOLO超参数优化的本质,不是“试遍所有参数”,而是“用工具化方法,在场景约束内找到最优平衡”——网格搜索稳、贝叶斯优化快,两者结合(先粗搜再精调)是工业场景的最优解。先定范围:基于工业场景(小目标/边缘设备/多类别)缩小参数搜索范围,避免无效探索。先调核心:优先优化数据增强、学习率、输入尺寸,这些参数对精度影响最大。工具赋能:用网格搜索+贝叶斯优化替代人工试错,再用TensorBoard监控,让调参“有据可依”。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 699

【施磊】C++课程笔记目录

【C++编程】施磊老师C++笔记目录

GeniusAng的博客 4128

【LeetCode】链表——回文链表

链接:https://leetcode-cn.com/explore/learn/card/linked-list/195/classic-problems/754/ 回文链表是指正序和逆序均相同的链表。 思路:使用快慢指针将链表一分为二,找到链表的中间节点后,将链表的后半部分进行反转,比较反转后的链表是否与前半部分相同,相同则为回文链表。 代码: /** * Definition for s...

Blog 593

高速特征金字塔多角度旋转模板匹配(工业零部件缺陷检测C++ Opencv版)

博主在性能较好的笔记本上测试算法全部执行效果大约为45ms,在一般配置的笔记本上博主在性能较好的笔记本上测试算法全部执行效果大约为130ms。下图即为实际检测效果。本文最后附有完整代码:Qt版和MFC版本(可直接运行)。...

认真努力,做一只会飞的毛毛虫。 5547

《LeetCode力扣练习》第234题 回文链表 Java

《LeetCode力扣练习》第234题 回文链表 Java 一、资源 题目: 给你一个单链表的头节点 head ,请你判断该链表是否为回文链表。如果是,返回 true ;否则,返回 false 。 示例 1: 输入:head = [1,2,2,1] 输出:true 示例 2: 输入:head = [1,2] 输出:false 提示: 链表中节点数目在范围[1, 105] 内 0 <= Node.val <= 9 进阶:你能否用 O(n) 时间复杂度和 O(1) 空间复杂度解决此题?

XRT_knives的博客 390

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

链表经典问题之回文链表(c++、Java)力扣leetcode234

方案一:栈遍历链表,将链表的每个节点的值存入一个栈中;再次遍历链表,比较链表节点的值和出栈的值是否相等,若有不等的则不是回文链表,否则是回文链表。方案二:快慢指针 + 反转链表使用快慢指针找到链表的中点,将链表分成两个部分;反转链表的后半部分;比较链表的前半部分和反转后的后半部分是否相等,若有不相等的则不是回文链表,否则是回文链表。方案三:递归使用快慢指针找到链表的中点,将链表分成两个部分;递归到链表的尾部,依次向前比较节点的值是否相等,若有不相等的则不是回文链表,否则是回文链表。

染落林间色的博客 1364

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

精选力扣500题 第40题 LeetCode 234. 回文链表【c++/java详细题解】

目录1、题目2、思路3、c++代码4、java代码 1、题目 请判断一个链表是否为回文链表。 示例 1: 输入: 1->2 输出: false 示例 2: 输入: 1->2->2->1 输出: true 进阶: 你能否用 O(n)O(n)O(n) 时间复杂度和 O(1)O(1)O(1) 空间复杂度解决此题? 2、思路 (链表操作) O(n)O(n)O(n) 假设初始的链表是 L1→L2→L3→…→LnL1→L2→L3→…→LnL1→L2→L3→…→Ln。 分两步处理:

林深不见鹿 的博客 3015

leetcode hot100【LeetCode 234. 回文链表】java实现

LeetCode 234. 回文链表

DataCrafter的博客 584

LeetCode 234. 回文链表(Java)

回文链表 请判断一个链表是否为回文链表。 示例 1: 输入: 1->2 输出: false 示例 2: 输入: 1->2->2->1 输出: true 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/palindrome-linked-list 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ...

nuts_and_bolts的博客 161

Java实现 LeetCode 234 回文链表

234. 回文链表 请判断一个链表是否为回文链表。 示例 1: 输入: 1->2 输出: false 示例 2: 输入...

5406

LeetCode 234. 回文链表 java

LeetCode 234. 回文链表 java 请判断一个链表是否为回文链表。 示例 1: 输入: 1-&gt;2 输出: false 示例 2: 输入: 1-&gt;2-&gt;2-&gt;1 输出: true JAVA 代码: class Solution { public boolean isPalindrome(ListNode head) { ListNode fa...

lele的专栏 509

leetcode234——回文链表——java实现

题目要求: 分析: 这道题目要求用O(1)的复杂度来做,那么我们就应该想到将这个链表从中间拆分开来进行比较。具体想法是这样的: 用快慢指针法找到这个链表的中点,记为middle; 取后半个链表,进行反转,反转链表之前做过; 将反转后的链表与前半个链表进行比较,如果相等,则返回true,如果不相等,则返回false。 具体代码如下: /** * Definition for singly-l...

阿花的IT历程 405

【LeetCode】234. 回文链表(Java)

解法一 数组 /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public boolean isPalindrome(ListNode head) { // 链表为空或者链表节点为1时,为回文链表

小楊同学的笔记本 557

力扣234 回文链表 Java版本

进阶:你能否用 O(n) 时间复杂度和 O(1) 空间复杂度解决此题?给你一个单链表的头节点 head ,请你判断该链表是否为。如果是,返回 true;否则,返回 false。链表中节点数目在范围[1, 105] 内。输入:head = [1,2,2,1]输入:head = [1,2]

m0_47066863的博客 518

leetcode234回文链表(JAVA版)

请判断一个链表是否为回文链表。 首先使用快慢指针,找到链表的中间节点,然后使用leetcode206 的方法反转链表,比较反转后的链表与前半部分是否相等 /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { publi

喂他柠檬茶的博客 196

leetcode234-回文链表 java

文章目录回文链表题目描述code方法一解题思路提交结果方法二 回文链表 题目描述 请判断一个链表是否为回文链表。 示例 1: 输入: 1->2 输出: false 示例 2: 输入: 1->2->2->1 输出: true code 方法一 解题思路 使用双指针做法,一个快指针,一个慢指针,当快指针走到链表结尾的时候,慢指针走向中间位置,然后使用栈stack 进行存储...

qq1010234991的博客 216
上一篇: LeetCode328. 奇偶链表(java)
下一篇: 数据结构---线段树
inferno devil
博客等级 码龄9年 54粉丝 172原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值