Shortest Distance Between 'X' and 'Y' in String

Easyglean

Given a string containing only the characters 'X', 'O', and 'Y'. Find the shortest distance between any 'X' and 'Y'. In this example, the answer is the smallest value between characters 'X' and 'Y' in...

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: