Re: [LeetCode] 刷到面試 Grind169 C++

看板Marginalman作者 (彗星雷達)時間2年前 (2023/03/15 11:25), 編輯推噓1(100)
留言1則, 1人參與, 2年前最新討論串5/14 (看更多)
125. Valid Palindrome easy題 也是雙指針的題 這次有想到怎麼解 但判斷大小寫的函數沒用過 所以還是有上網查 class Solution { public: bool isPalindrome(string s) { int start = 0; const int n = s.length(); int end = n-1; while(start<end){ while(start<end && !isalnum(s[start])) start++; while(start<end && !isalnum(s[end])) end--; if(tolower(s[start])!=tolower(s[end])) return false; start++; end--; } return true; } }; -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.113.136.220 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1678850748.A.640.html

03/15 11:26, 2年前 , 1F
大師
03/15 11:26, 1F
文章代碼(AID): #1a4JgyP0 (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1a4JgyP0 (Marginalman)