Re: [闲聊] 每日leetcode

楼主: sustainer123 (caster)   2024-04-01 10:50:50
※ 引述《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纾压 等等又要写图的题目 想死

Links booklink

Contact Us: admin [ a t ] ucptt.com