In a DatologyAI coding mock, test a cursor moving across an edit at index zero before optimizing the editor. For infrastructure roles, follow that with a reproducible dataset pipeline discussion.
What to prepare for DatologyAI
A candidate account describes a multipart text-editor task. DatologyAI's data-infrastructure posting is an independent guide to team context. The editor below is an original single-line simplification. PracHub also indexes a mock distributed-data operations problem for the company. DatologyAI software engineer, data infrastructure role, DatologyAI SWE text-editor candidate account
Implement insertion and backspace at a cursor
Keep a cursor between characters, with zero before the first character. Support inserting an entire string, a left move that clamps at zero, a right move that clamps at the end and a backspace that leaves an empty left side unchanged. PracHub practice question
class Editor:
def __init__(self):
self.left, self.right = ([], [])
def insert(self, text):
self.left.extend(text)
def back(self):
if self.left:
self.left.pop()
def move_left(self):
if self.left:
self.right.append(self.left.pop())
def move_right(self):
if self.right:
self.left.append(self.right.pop())
def render(self):
return ''.join(self.left) + ''.join(reversed(self.right))
e = Editor()
e.back()
e.move_left()
assert e.render() == ''
e.insert('ab')
e.move_left()
e.insert('X')
assert e.render() == 'aXb'
e.back()
e.move_right()
assert e.render() == 'ab'
Use two stacks: characters to the left in reading order and characters to the right in reverse. Moving transfers one character, deletion pops the left stack, and insertion appends characters. Per-key edits are O(1), a paste is O(k), rendering O(n), and storage O(n).
Walk through a boundary case
After inserting “ab”, shift one position left and insert “X”. Left stack holds a,X and right stack holds b. Rendering gives aXb. Backspace removes X, then moving right reconstructs ab at the end. Test the same operations at zero. For multi-line text, decide whether character indices count code points, bytes or user-visible graphemes before adding a cursor persistence format.
Preserve source references when a duplicate source disappears
Group examples by a deterministic precomputed content key. Removing one source reference should leave a duplicate available through a surviving record. Test two partition orders and compare the normalized result rather than the sequence in which groups happened to be visited.
from collections import defaultdict
def manifest(rows, removed):
group = defaultdict(set)
for key, source in rows:
if source not in removed:
group[key].add(source)
return {key: sorted(sources) for key, sources in group.items()}
rows = [('same', 'a'), ('same', 'b'), ('other', 'c')]
assert manifest(rows, {'a'}) == {'same': ['b'], 'other': ['c']}
assert manifest(reversed(rows), {'a'}) == manifest(rows, {'a'})
Design and debugging follow-up
For a distributed data follow-up, deduplicate identical examples by content key while retaining all source references. If one source record is deleted, the shared content may still be valid through another reference. Give each training snapshot an immutable manifest, and test the same pipeline with changed partition order and a record removed.
What to bring to a mock interview
Prepare a project story that distinguishes deterministic outputs from deterministic processing order. Bring a fixture with repeated characters, edits at zero, plus a tiny corpus whose partitioning changes without changing its final aggregate.