Substring access by indices
TypeScript
Medium
strings
Task «Substring access by indices»
Given a string S and two integers a and b (indices). It is necessary to reverse the substring from index a to b inclusive. If a > b, then reverse from b to a. Indexing starts from 0. It is guaranteed that the indices do not go out of bounds of the string.
Input Format
First line: string S (1 ≤ |S| ≤ 1000). Second line: two integers a and b (0 ≤ a, b < |S|).
Output Format
One line — the result after reversing the specified substring.
main.ts