Skip to content

Commit 61296e3

Browse files
solves length of last word in python
1 parent 6756c5c commit 61296e3

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

python/length_of_last_word.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def length_last_word(s: str) -> int:
2+
s = s.strip()
3+
for index in range(len(s) - 1, -1, -1):
4+
if s[index] == ' ':
5+
return len(s) - index - 1
6+
return len(s)
7+
8+
9+
print(length_last_word(input()))

src/CountAndSay.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import java.util.ArrayList;
22
import java.util.List;
3-
import java.util.Scanner;
43

54
public class CountAndSay {
65
private static String countAndSay(int number) {

src/FindModeInBinarySearchTree.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public class FindModeInBinarySearchTree {
2+
3+
}

0 commit comments

Comments
 (0)