FastPrepLast and Second-Last

Last and Second-Last

Oracle logoOracle● EasyFULLTIMEOA

Problem statement

Given a string, create a new string made up of its last two letters, reversed and separated by a space.

Function

lastLetters(word: String) → String

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

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.

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

See Oracle hiring insights
Saved
public String lastLetters(String word) {
    // write your code here
}
word"APPLE"
expected"E L"
Checking account…