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
Video Caption to Hashtag Transformation"Hello, World! 123"Mixed characters & symbolsInput CaptionExtract: Hello, WorldcamelCase: hello + WorldProcessing Steps#helloWorldClean hashtag formatFinal OutputTransformation Rules1. Extract words (letters only)2. First word → lowercase, others → Capitalize3. Add # prefix4. Truncate to 100 characters✓ Perfect for social media hashtags!
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
Asked in
Meta 25 Twitter 30 TikTok 20 Instagram 15
23.5K Views
Medium Frequency
~15 min Avg. Time
890 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen