Explanation

581.Trim Spaces from a Line of Text

Easy
Given a line of text exactly as a user typed it, return it with all spaces at the start and end removed. Spaces between words must stay. When a program reads a whole line of input — nextLine(), input(), getline, fgets — it receives every character typed, including accidental spaces at the edges. TrimmingTrimmingRemoving whitespace from the beginning and end of a string, without touching the inside. that input is usually the first thing to do, so that later comparisons and conversions work on the real content.

Example 1:

Input: text = " hello world "

Output: "hello world"

Example 2:

Input: text = "ready"

Output: "ready"

+ 4 hidden test cases run on Submit.

Constraints:

  • ●1 ≤ text.length ≤ 200
  • ●text contains printable ASCII characters and at least one non-space character

text =

hello world