PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/IBM

Reverse last two characters with space

Last updated: Apr 25, 2026

Quick Overview

This question evaluates basic string manipulation and character indexing skills, including handling of edge cases when treating input as a raw character array. Commonly asked in Coding & Algorithms interviews, it tests practical implementation ability and attention to indexing and boundary conditions, classifying the task as a practical application in the string-manipulation domain.

  • nan
  • IBM
  • Coding & Algorithms
  • Software Engineer

Reverse last two characters with space

Company: IBM

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: nan

Interview Round: Technical Screen

## Problem Given a non-empty string `s` with length at least 2, output a new string consisting of the last two characters of `s` in reverse order, separated by a single space. ### Input - A string `s` (length `>= 2`). ### Output - A string of the form: `s[last] + " " + s[second_last]`. ### Example - Input: `"bat"` - Output: `"t a"` ### Edge Cases - `s` may contain letters, digits, or other characters; treat it as a raw character array/string. - Example: `"ab" -> "b a"`.

Quick Answer: This question evaluates basic string manipulation and character indexing skills, including handling of edge cases when treating input as a raw character array. Commonly asked in Coding & Algorithms interviews, it tests practical implementation ability and attention to indexing and boundary conditions, classifying the task as a practical application in the string-manipulation domain.

Related Interview Questions

  • Compute minimum rooms for meeting schedule - IBM (nan)
  • Maximize palindromic strings after character swaps - IBM (medium)
  • Find minimum subarray length with k distinct integers - IBM (medium)
  • Find minimum operations to make array sorted - IBM (easy)
  • Implement valid 1-D convolution - IBM (Medium)
IBM logo
IBM
Mar 1, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
5
0
Loading...

Problem

Given a non-empty string s with length at least 2, output a new string consisting of the last two characters of s in reverse order, separated by a single space.

Input

  • A string s (length >= 2 ).

Output

  • A string of the form: s[last] + " " + s[second_last] .

Example

  • Input: "bat"
  • Output: "t a"

Edge Cases

  • s may contain letters, digits, or other characters; treat it as a raw character array/string.
  • Example: "ab" -> "b a" .

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More IBM•More Software Engineer•IBM Software Engineer•IBM Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.