PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

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.

Return last character, a space, then second-last character.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ('bat',)

Expected Output: 't a'

Explanation: Prompt example.

Input: ('ab',)

Expected Output: 'b a'

Explanation: Minimum length.

Input: ('x9!',)

Expected Output: '! 9'

Explanation: Raw characters.

Hints

  1. Model object-style prompts as operation streams when needed.
  2. Handle empty and boundary cases before the main logic.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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.

Related Coding 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)
  • Compute shared free time intervals - IBM (Medium)