Problem · String
Last and Second-Last
Learn this problemProblem 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
- Alphabetically Maximum SubstringPHONE SCREEN · Seen Jul 2026
- Best Time to Buy and Sell StockPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Enumerate Right-and-Down Matrix PathsONSITE INTERVIEW · Seen Jul 2026
- Maximize Movie Ratings Without Consecutive SkipsONSITE INTERVIEW · Seen Jul 2026
- Add One to a Number Represented as DigitsONSITE INTERVIEW · Seen Jul 2026
- Top K Frequent Elements with Larger-Value Tie BreakONSITE INTERVIEW · Seen Jul 2026
- Merge k Sorted ListsPHONE SCREEN · Seen Jul 2026
- Implement a Queue Using Two StacksPHONE SCREEN · Seen Jul 2026