Re: [閒聊] 每日leetcode

看板Marginalman作者 (caster )時間1年前 (2024/04/01 10:50), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串85/1548 (看更多)
※ 引述《SecondRun (南爹摳打)》之銘言: : 58.Length of Last Word : 找出字串s裡最後面一個字的長度 : 想法:沒有 : public class Solution { : public int LengthOfLastWord(string s) { : return s.Trim().Split(' ').Last().Length; : } : } : 我只會EZ 思路: 分割切片算長度 Python Code: class Solution: def lengthOfLastWord(self, s: str) -> int: return len(s.split()[-1]) 刷ez紓壓 等等又要寫圖的題目 想死 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.43.132.166 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1711939853.A.B19.html
文章代碼(AID): #1c2Y4DiP (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1c2Y4DiP (Marginalman)