Generate Tag for Video Caption - Problem
You are given a string caption representing the caption for a video. You need to generate a valid tag for the video by performing the following actions in order:
1. Combine all words into a single camelCase string prefixed with '#'. A camelCase string is one where the first letter of all words except the first one is capitalized, and all other characters are lowercase.
2. Remove all non-English letters except the first '#' character.
3. Truncate the result to a maximum of 100 characters.
Return the generated tag after performing these operations on the caption.
Input & Output
Example 1 — Basic Case
$
Input:
caption = "Hello World!"
›
Output:
#helloWorld
💡 Note:
Words are 'Hello' and 'World'. First word becomes lowercase 'hello', second becomes 'World'. Result: '#helloWorld'
Example 2 — With Numbers and Symbols
$
Input:
caption = "Coding123 is FUN!!!"
›
Output:
#codingIsFun
💡 Note:
Extract words 'Coding', 'is', 'FUN'. Apply camelCase: 'coding' + 'Is' + 'Fun' = '#codingIsFun'
Example 3 — Single Word
$
Input:
caption = "AWESOME"
›
Output:
#awesome
💡 Note:
Single word 'AWESOME' becomes lowercase 'awesome' as the first word. Result: '#awesome'
Constraints
- 1 ≤ caption.length ≤ 105
- caption consists of English letters, digits, spaces, and punctuation marks
Visualization
Tap to expand
Understanding the Visualization
1
Input
Raw caption with mixed characters, punctuation, numbers
2
Extract & Transform
Find words, apply camelCase, remove non-letters
3
Output
Clean hashtag with proper formatting and length limit
Key Takeaway
🎯 Key Insight: Extract words first, then apply formatting rules systematically - much cleaner than processing character by character
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code