Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 376 Bytes

58.最后一个单词的长度.md

File metadata and controls

26 lines (21 loc) · 376 Bytes
title categories
最后一个单词的长度
leetcode
leetcode题解
package main

import "strings"

/*
 * @lc app=leetcode.cn id=58 lang=golang
 *
 * [58] 最后一个单词的长度
 */

// @lc code=start
func lengthOfLastWord(s string) int {
	words := strings.Split(strings.TrimSpace(s), " ")

	return len(words[len(words)-1])
}

// @lc code=end