PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Jerry.Ai

Determine a one-step string transformation

Last updated: May 5, 2026

Quick Overview

This question evaluates proficiency in string manipulation and algorithmic reasoning, focusing on edit operations, positional changes, and edge-case handling.

  • medium
  • Jerry.Ai
  • Coding & Algorithms
  • Software Engineer

Determine a one-step string transformation

Company: Jerry.Ai

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

Given two lowercase strings `source` and `target`, determine whether `target` can be obtained from `source` using at most one of the following operations, and output one valid operation if possible. Allowed operations: 1. `add c`: Insert one character `c` at any position in `source`. 2. `delete c`: Delete one occurrence of character `c` from `source`. 3. `replace x y`: Replace one occurrence of character `x` in `source` with character `y`. 4. `move c`: Remove one occurrence of character `c` from its current position and insert it at another position in the string. If `source` is already equal to `target`, output `no_change`. If no single operation can transform `source` into `target`, output `impossible`. If multiple valid operations exist, output any one valid operation. Examples: ```text source = "baren", target = "bbren" output: replace a b ``` ```text source = "banan", target = "banana" output: add a ``` ```text source = "abcde", target = "acdeb" output: move b ``` Expected follow-up: design an efficient solution that handles long strings, ideally in linear time.

Quick Answer: This question evaluates proficiency in string manipulation and algorithmic reasoning, focusing on edit operations, positional changes, and edge-case handling.

Jerry.Ai logo
Jerry.Ai
Jan 1, 2026, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
0
0

Given two lowercase strings source and target, determine whether target can be obtained from source using at most one of the following operations, and output one valid operation if possible.

Allowed operations:

  1. add c : Insert one character c at any position in source .
  2. delete c : Delete one occurrence of character c from source .
  3. replace x y : Replace one occurrence of character x in source with character y .
  4. move c : Remove one occurrence of character c from its current position and insert it at another position in the string.

If source is already equal to target, output no_change. If no single operation can transform source into target, output impossible. If multiple valid operations exist, output any one valid operation.

Examples:

source = "baren", target = "bbren"
output: replace a b
source = "banan", target = "banana"
output: add a
source = "abcde", target = "acdeb"
output: move b

Expected follow-up: design an efficient solution that handles long strings, ideally in linear time.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Jerry.Ai•More Software Engineer•Jerry.Ai Software Engineer•Jerry.Ai 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.