首页 > 代码库 > leetcode58

leetcode58

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

leetcode58