精華區beta Marginalman 關於我們 聯絡資訊
※ 引述《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