#297. 字符串首尾字符处理

    ID: 297 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatString-1gesp3字符串

字符串首尾字符处理

Remove 'x' from String Ends

Background

Congcong is currently learning string manipulation. He encountered an interesting problem that requires specific modifications to a string.

Problem Description

Given a string, if its first character or last character is 'x', return the string without those 'x' characters; otherwise, return the string unchanged.

Input Format

The input is given from standard input in the following format.

A single line, containing a string SS.

Output Format

The output is printed to standard output in the following format.

A single line, containing the processed string.

Sample

xHix
Hi
xHi
Hi
Hxix
Hxi

Sample Explanation

  • Sample 1: Input "xHix". The first character is 'x', and the last character is also 'x'. Removing both 'x's results in "Hi".
  • Sample 2: Input "xHi". The first character is 'x', and the last character is not 'x'. Removing the first 'x' results in "Hi".
  • Sample 3: Input "Hxix". The first character is not 'x', and the last character is 'x'. Removing the last 'x' results in "Hxi".

Constraints

Time limit: 1s, Memory limit: 1024KiB for each test case.