Skip to content

Commit

Permalink
Merge pull request #21 from Athi223/qn-58
Browse files Browse the repository at this point in the history
Added solution for 58. Length of Last Word
  • Loading branch information
adithyapaib committed Oct 20, 2022
2 parents 6aa91dc + b002288 commit b53946b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 58. Length of Last Word/README.md
@@ -0,0 +1,12 @@
## 58. Length of Last Word
Given a string `s` consisting of words and spaces, _return the length of the **last** word in the string._

A **word** is a maximal substring consisting of non-space characters only.

## Python

```python
class Solution:
def lengthOfLastWord(self, s: str) -> int:
return len(s.strip().split()[-1])
```

0 comments on commit b53946b

Please sign in to comment.