Shortest Distance to Target Character

Problem: Shortest Distance from Each Position to a Target Character

Given a string s of length n and a target character target, return an integer array ans of length n, where ans[i] is...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: