3893. Generate Tag for Video Caption
My accepted Python solution to LeetCode problem 3893, Generate Tag for Video Caption, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.3MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.3MB, accepted 2025-12-31.
class Solution:
def generateTag(self, caption: str) -> str:
words = caption.split()
result = '#'
for i, word in enumerate(words):
# Keep only letters
cleaned = ''.join(c for c in word if c.isalpha())
if not cleaned:
continue
if i == 0:
result += cleaned.lower()
else:
result += cleaned[0].upper() + cleaned[1:].lower()
return result[:100]