Company: Microsoft_12july

Difficulty: medium

Problem Statement

Text Editor Problem Description Build a simplified model of a text editor that supports the following operations: ["Insert", s] : Place the string s right at the cursor's current location. After inserting, the cursor shifts rightward by the number of characters just added. ["Print", x] : With the cursor sitting at position m , output every character spanning from m - x through m + x . ["Left", x] : Shift the cursor x spots toward the start. ["Right", x] : Shift the cursor x spots toward the end. ["Backspace", x] : Erase the x characters sitting immediately before the cursor. ["Delete", x] : Erase the x characters sitting immediately after the cursor. You receive a 2-D array of strings sized n x 2 named commands . Beginning from an empty document with the cursor at its starting spot, work out the text produced at each print step and return these results as an ordered array of strings. Whenever a move would push the cursor past either edge of the current text, the cursor simply stops at

More Microsoft_12july OA questionsInterview experiences