【leetcode】125.(Easy)Valid Palindrome

125. Valid Palindrome [easy] (Python) 125. Valid Palindrome [easy] (Python)题目链接https://leetcode.com/problems/valid-palindrome/题目原文 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cas 阅读详情

解题思路:

双指针
时间复杂度:O(n)

提交代码:

class Solution {
    public boolean isPalindrome(String s) {
    	int p1=0,p2=s.length()-1;
    	while(p1<p2) {
    	while(!isChar(s.charAt(p1))&&p1<p2)
    			p1++;
    	while(!isChar(s.charAt(p2))&&p2>p1)
    			p2--;
    	if(p1>=p2)	break;
    	if(reshape(s.charAt(p1))!=reshape(s.charAt(p2)))
    		return false;
    	p1++;p2--;
    	}
    	return true;
    }
    
    private boolean isChar(char c) {
    	if(c-'a'>=0&&c-'a'<26)	return true;
    	if(c-'A'>=0&&c-'A'<26)	return true;
    	if(c-'0'>=0&&c-'0'<=9)	return true;
    	return false;
    }
    
    private char reshape(char c) {
    	char newChar='a';
    	if(c-'A'>=0&&c-'A'<26) {
    		newChar=(char)('a'+c-'A');
    		return newChar;
    	}
    	return c;
    }
}

运行结果:
在这里插入图片描述

开源大模型本地部署实战:Llama、DeepSeek、Qwen选型与工程落地指南 大语言模型(LLM)本地部署已成为AI工程化核心环节,其本质不是比拼参数量或榜单分数,而是考察模型架构、推理引擎、量化支持、IDE集成与多模态扩展能力的系统性适配。Llama以纯净Transformer结构成为通用底座,依赖llama.cpp和GGUF量化实现跨平台轻量推理;DeepSeek深度优化代码与数学推理,通过原生OpenAPI、FlashAttention-2及tensor parallelism显著降低API延迟;Qwen则采用模块化设计,支持视觉编码器(Qwen-VL)、生物计算(Qwen-B 阅读详情

相关推荐

winServer2008下安装SqlServer2008数据库

1 安装文件包 文件名 cn_sql_server_2008_r2_enterprise_x86_x64_ia64_dvd_522233.iso SHA1 0EEFF017B21635DF33F33C47E31E911CB23390F7 文件大小 4.34GB 发布时间 2010-05-03 ed2k://|file|cn_sql_server_2008_r2_enterprise_x86_x64_ia64_dvd_522233.iso|4662884352|1DB025218B01B48C6B76D6D8

IChen.的博客 4386

Leetcode OJ 125 Valid Palindrome [Easy]

Leetcode OJ 125 Valid Palindrome 题目描述: Given a string, determine if it is a palindrome,considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama"

大吱的博客 344

PRIDE PPP-AR软件实战:从ZTD解算到PWV反演的全流程避坑指南

本文详细解析了使用PRIDE PPP-AR软件进行GNSS数据处理的全流程,重点涵盖从ZTD解算到PWV反演的关键步骤与精度评估。文章深入剖析了软件部署、数据准备、参数配置中的常见“坑点”,并提供了与IGS ZTD及ERA5产品进行交叉验证的实用方法,旨在帮助用户高效、准确地获取高精度大气可降水量产品。

p8q9r0的博客 626

[Leetcode 125, easy] Valid Palindrome

[Leetcode 125, easy] Valid Palindrome

算法的实践 445

AGI 之 【Dify】 之 Dify 在 Windows 端本地部署调用 Ollama 本地下载的大模型, API 形式 Python 调用 进行简单聊天接口测试

AGI,即通用人工智能(Artificial General Intelligence),是一种具备人类智能水平的人工智能系统。它不仅能够执行特定的任务,而且能够理解、学习和应用知识于广泛的问题解决中,具有较高的自主性和适应性。AGI的能力包括但不限于自我学习、自我改进、自我调整,并能在没有人为干预的情况下解决各种复杂问题。本节将介绍如何使用 Dify 平台调用 Ollama 部署的本地模型来创建一个聊天应用。通过 API 的方式发起聊天,可以让前端自由布置所需的聊天形式。

仙魁XAN 1万+

【PG高可用】一 PostgreSQL高可用方案repmgr部署(非常详细)

repmgr安装部署

DBA之路的博客 7060

LeetCode - Easy - 125. Valid Palindrome

Topic String Two Pointers Description https://leetcode.com/problems/valid-palindrome/ Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty str

KISS 199

harbor x509: certificate signed by unknown authority【20251222】

本教程通过「合并证书链(服务器端)+ 预置根 CA(客户端)」彻底解决了自签名证书的 x509 错误,同时集成了 Trivy 漏洞扫描,实现了 Harbor 从搭建到实用的全流程。证书链合并是服务器端的关键,确保客户端获取完整信任路径;客户端需同时配置「系统信任库 + Docker 信任目录」,避免 Docker 独立信任机制导致的问题;所有 IP 需保持一致(Harbor 配置、证书绑定、客户端访问),是避免错误的基础。

老韩的Linux云计算架构师进阶之路 687

leetcode 125. Valid Palindrome (easy)

学习到了几种stl的用法 transform(b1,e1,b2,op) 按op的规则将b1,e1范围内的元素筛选到b2 prev(it) 获取it的前一个迭代器,对应的是distance() isalnum(char) 判断是否是字母or数字 isalpha(char) 判断是否是字母 这题要注意数字也算在要被识别的范围内 class Solution { public: bool isPali...

Rh's blog 145

03 - AMDGPU驱动架构概览

本文介绍了AMDGPU驱动的整体架构,重点分析其图形驱动(AMDGPU)和计算驱动(KFD)的双重结构。KFD驱动作为HSA架构的核心组件,包含进程管理、设备管理等模块,其中SVM功能在kfd_svm.c实现。文章详细解析了KFD的核心组件、初始化流程及字符设备接口,并阐述了TTM框架在GPU内存管理中的作用。通过架构图和代码片段展示了AMDGPU与KFD的协作机制,为后续深入理解SVM实现奠定基础。

图形/计算GPU的驱动与虚拟化技术分享园地 3417

论文深度解析:基于大语言模型的城市公园多维度感知解码与公平性提升

本文针对城市公园感知测量的精细化不足与公平性评估缺口,提出了一套融合社交媒体数据与大语言模型(LLM)的创新分析框架。通过领域适配微调开发的Park-Perception-LLM模型,实现了对感知可达性、可用性、吸引力三大核心维度83%-91%的高精度分类。将该感知指标创新性地融入增强两步浮动集水区法(E2SFCA),以香港高密度城市为案例,系统揭示了公园质量与数量的空间不平等及错配模式。借助多元回归模型,深入挖掘了公园内部特征、宏观建成环境、微观街道景观及时间因素对感知的影响机制。

May the Force be with you 1027

【LeetCode】 125. Valid Palindrome 验证回文串(Easy)(JAVA)

【LeetCode】 125. Valid Palindrome 验证回文串(Easy)(JAVA) 题目地址: https://leetcode.com/problems/valid-palindrome/ 题目描述: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this

qq_16927853的博客 173

Dify使用教程3:Dify创建工作流

Dify使用教程3:Dify创建工作流 接着,我们连接下一个节点:“LLM”填入上下文变量为:result。这时候知识库就添加成功了。添加新节点:结束节点。

拥抱具身智能,昇腾Ascend C 5142

LeetCode Top Interview Questions 125. Valid Palindrome (Java版; Easy)

welcome to my blog LeetCode Top Interview Questions 125. Valid Palindrome (Java版; Easy) 题目描述 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring case...

littlehaes的博客 205

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Leetcode 125. Valid Palindrome (Easy) (cpp)

Leetcode 125. Valid Palindrome (Easy) (cpp)

还是需要多学习!闷声大发财,这是坠吼的! 374

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

【python】leetcode 125. Valid Palindrome (easy)

125. Valid Palindrome (easy) Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty str...

momottyy的专栏 181

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

LeetCode-Easy部分中标签为Two Pointers 125. Valid Palindrome

判断一个字符串是不是`回文` 字符串。首、尾指针分别指向有效字符或数字,一一比较,若过程中出现不等,直接返回false,若两个指针碰头了,表示字符首、尾都相等,返回true。

相信相信的力量 949

leetcode 125 Valid Palindrome(难易度:Easy)

Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "rac

zhutianyu_123的专栏 297

【LeetCode系列】Leet Code OJ 125. Valid Palindrome [Difficulty: Easy]

题目链接 本来觉得是一个进栈出栈的问题,后来想想,反转一下就行了,这样也不用考虑奇数偶数。而且用Python来写感觉就像是作弊一样,直接有转换成大小写的方法了。 class Solution: def isPalindrome(self, s): """ :type s: str :rtype: bool """ ...

u013379032的博客 222

leetcode 125.valid-palindrome 验证回文串 python3

时间:2020-5-17 题目地址:https://leetcode-cn.com/problems/valid-palindrome/description/ 题目难度:Easy 题目描述: 给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。 说明:本题中,我们将空字符串定义为有效的回文串。 示例 1: 输入: "A man, a plan, a canal: Panama" 输出: true 示例 2: 输入: "race a car" 输出: false

isabloomingtree的博客 246

leetcode125. Valid Palindrome

easy程度题 题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "rac

ProgrammingLearner的博客 381

leetcode125-Valid Palindrome

难度:easy Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car

fawnzou2017的博客 211

LeetCode 125. Valid Palindrome

125. Valid Palindrome My Submissions QuestionEditorial Solution Total Accepted: 99300 Total Submissions: 417275 Difficulty: Easy Given a string, determine if it is a palindrome, considering only al

柳婼 の blog 335

【String-easy】125. Valid Palindrome 串是否是回文字符串

1. 题目原址 https://leetcode.com/problems/valid-palindrome/ 2. 题目描述 3. 题目大意 给定一个字符串,判断这个字符串是否是回文字符串 4. 解题思路 因为字符串中存在空格等,所以我们需要将字符串的空格去掉,去掉的方法就是新定义一个字符数组,将原字符数组中的元素放到新的字符数组中,将空格的元素去掉,不加到新的字符数组中。因此需要使用一个i...

想当厨子的程序媛 352

Leet Code OJ 125. Valid Palindrome [Difficulty: Easy] -python

题目: 125.Valid Palindrome Easy Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note:For the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: "A man,..

渣渣琪的博客 242

[LeetCode]125. Valid Palindrome

题目描述:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, “A man, a plan, a canal: Panama” is a palindrome. “race a car

zxiang248的专栏 272
上一篇: 【leetcode】122.(Easy)Best Time to Buy and Sell Stock II
下一篇: 【leetcode】127.(Medium)Word Ladder
AXIMI
博客等级 码龄10年 53粉丝 455原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值