Problem · String
Last and Second-Last
Given a string, create a new string made up of its last two letters, reversed and separated by a space.
Complete the function lastLetters in the editor below.
lastLetters has the following parameter(s):
string word: a string to process
Returns
string: a string of two space-separated characters
Examples
01 · Example 1
word = "APPLE" return = "E L"
The last letter in 'APPLE' is E and the second-to-last letter is L, so return E L.
02 · Example 2
word = "bat" return = "t a"
Just an example provided by Oracle with no explanation 🥲🔫
Constraints
2 ≤ length of word ≤ 100
More Oracle problems
public String lastLetters(String word) {
// write your code here
}
word"APPLE"
expected"E L"
sign in to submit