Given a string s and a number n, return a new string made of the last character of s, written n times in a row.
Example 1:
Input: s = "banana", n = 3 Output: "aaa" Explanation: The last character of "banana" is "a". Written 3 times, it gives "aaa".
Example 2:
Input: s = "Wow!", n = 2 Output: "!!" Explanation: The last character can be any character: here it is the exclamation mark.
Example 3:
Input: s = "z", n = 1 Output: "z" Explanation: A string of one character: its last character is "z", written once.
Constraints:
shas at least one character and doesn't start or end with a space.scontains English letters, digits, spaces and punctuation.nis a whole number from 1 to 10.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
