All practice tasks

Coding (Algo)

Minimal Sync Deletions

Dynamic programming · Hard

Two offline event histories must agree on a shared order. Reconciliation may delete events from either history but cannot reorder or insert them.

Return the minimum total number of deletions needed to make the histories identical.

Input

Call

  • Implement solve(input) and return its result. Do not print from solve.

Input object

{ local:string, remote:string }

Input rules

  • Each lowercase ASCII character represents an event kind; repetitions matter.

What each field means

  • local and remote — event histories; each character is one event occurrence.

Output

Return value and rules

  • Return the fewest total character deletions needed to make both histories identical.
  • You may delete from either history, but may not insert, replace or reorder characters.
  • Return the deletion count, not the remaining history.

Constraints

  • 0 <= local.length, remote.length <= 2000
  • Use memory linear in the shorter history, not a quadratic table.

Examples

Example 1

{
  "local": "abc",
  "remote": "adc"
}

Returns

2

Example 2

{
  "local": "",
  "remote": ""
}

Returns

0

Required complexity

O(nm) time and O(min(n,m)) auxiliary space

What this task practices

Minimal Sync Deletions is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as hard difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.