iOS Dev India
Learn
Roadmap
Skills
Swift DSA
Build
Studio
Sandbox
Tools
Agent Skills
Community
Communities
Events
Library
Articles
Resources
Jobs
Create Profile
Home
Learn
Roadmap
Skills
Swift DSA
Build
Studio
Sandbox
Tools
Agent Skills
Community
Communities
Events
Library
Articles
Resources
Jobs
Create Profile
Challenges
/
Capitalize Word
·
Step 20/100 · Sets & Hashing
← Count Spaces
Second Largest →
Description
Hint
Capitalize Word
L1
Easy
Strings
Concept
Rebuilding a string from parts — a singled-out first character plus the rest — is a core string manipulation habit.
Return
s
with only its first character capitalized. If
s
is empty, return an empty string.
Examples
▸
s = "swift"
→ "Swift"
▸
s = "Swift"
→ "Swift"
▸
s = ""
→ ""
Progressive Hints
Hint 1 · Nudge
You're rebuilding the word from two pieces: the first letter, and everything after it.
Hint 2 · Plan
Handle the empty string first. Uppercase the first character, then attach the rest of the string unchanged. Return the rebuilt string.
Hint 3 · Approach
If s is empty return empty. Else return uppercase(first character) with the remaining characters appended.
Reveal the next hint
All hints are out. Take a breath and give it a shot.
Swift
Java
Solution.swift
Tests.swift (Read Only)
Run
Output
// Run your code to see the output here.
Press
ESC
to close.
Start typing to search...