- Text Editor
In this task, a prototype for a text editor application is to be
implemented consisting of the following functionalities:
Command Action
["Insert”, s] Insert the string at the current cursor
position,
the cursor will also move to the right by
the length of the inserted string
["Print", x] If the cursor is at position m, print all the
characters from m - x to m + x
["Left", x] Move the cursor x positions to the left
["Right", x] Move the cursor x positions to the right
["Backspace", Remove x characters to the left of the
x] cursor
["Delete", x] Remove x characters to the right of the
cursor
Given a 2-d array of strings size n x 2, commands, find the string
obtained on each of the print operations by performing the
above operations starting from an empty string and cursor at
the starting position and report them as an array of printed
Given a 2-d array of strings size n x 2, commands, find the string
obtained on each of the print operations by performing the
above operations starting from an empty string and cursor at
the starting position and report them as an array of printed
strings in order. If for any operation the cursor reaches the
beginning or the end of the current string, it does not go any
further on the either side.
Note: For consistency, the second argument is always provided
as a string and hence might be required to be converted to an
integer for the relevant commands.
Example
Suppose n = 6 and commands =[["Insert", "hello"], ["Left", "3"],
["Delete", "1"], ["Right", "2"], ["Backspace", "1"], ["Print", "4"]].
Current | Current Final Final
| Command String | Cursor | String | Cursor Prin
Insert "hello" 0 "hello" | 5
"hello" | (after 0)
Left 3 "hello" 5 "hello" | 2
| (after e)
Delete 1 | "hello" 2 "helo" | 2
(after e)
Right 2 | "helo" 2 | "helo" 4 | (after o)
4.
Implement a prototype of a time-tolive cache.
Given a 2-d array of integers of size n x 2 data, datali] represents that the ith data pointwas inserted into the cache at time datalil0j lt lives in the cache for datalil[1] time. Foran array of g queries, queries[q], find the number of data items in the cache at eachtime querylil.
ExampleSuppose n = 3, data = [[105231, 183], [105334, 34], [105198, 543]], g = 2, and queries =[1053381054101
接受预约中,包AC
我们可以在线协助您通过任何的OA,不管是开摄像头还是任何作弊检测方案我们都能够绕过
Accepting bookings, ensure AC.
We can assist you online with any online assessment, and we can bypass any cheating detection mechanisms, including those that require the use of a camera
contact me to slove OA (Paid )