Given a string s, return a new string made of two characters: the first character of s, followed by its last character.
Example 1:
Input: s = "hello" Output: "ho" Explanation: The first character is "h" and the last one is "o".
Example 2:
Input: s = "Hello World!" Output: "H!" Explanation: Every character counts, so the last one is the "!", not the "d". The "H" stays upper case.
Example 3:
Input: s = "ab" Output: "ab" Explanation: With only two characters, the first is "a" and the last is "b".
Constraints:
shas at least 2 characters.scontains English letters, digits, spaces and punctuation, and doesn't start or end with a space.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
