public class Solution { public int LengthOfLastWord(string s) { s = s.Trim(); if (s.Length == 0 || s.Trim().Length == 0) { return 0; } var len = s.Length; var list = s.Split(‘ ‘); var word = list[list.Length - 1]; return word.Length; } }
https://leetcode.com/problems/length-of-last-word/#/description
时间: 2024-10-10 16:44:33