Skip to content

Commit cca8d08

Browse files
committed
Runtime 35 ms (Top 41.6%) | Memory 16.0 MB (Top 7.45%)
1 parent 346c8e5 commit cca8d08

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
class Solution:
22
def capitalizeTitle(self, title: str) -> str:
3-
return " ".join([word.capitalize() if len(word) > 2 else word.lower() for word in title.split()])
3+
li = title.split()
4+
for i,l in enumerate(li):
5+
if len(l) <= 2:
6+
li[i] = l.lower()
7+
else:
8+
li[i] = l[0].upper() + l[1:].lower()
9+
return ' '.join(li)

0 commit comments

Comments
 (0)