#C14637. Reverse Strings
Reverse Strings
Reverse Strings
You are given a JSON array containing various elements. Your task is to reverse each string element while maintaining their original order. Non-string elements should be ignored.
For example, given the array
( ["apple", "banana", "cherry"] )
the output should be
( ["elppa", "ananab", "yrrehc"] ).
The input will be provided as a single line from standard input (stdin) in valid JSON format and you should print the result as a JSON array to standard output (stdout).
inputFormat
The input is a single line containing a valid JSON array. The array may contain strings as well as non-string values. Only reverse the string elements.
Example:
["apple", "banana", "cherry"]
outputFormat
Output a single line containing a JSON array of reversed strings (in the same order as they appear in the input). If no strings exist, output an empty JSON array.
Example:
["elppa", "ananab", "yrrehc"]## sample
["apple", "banana", "cherry"]
["elppa", "ananab", "yrrehc"]