Metric Namespace Root judge accepts solutions that ignore middle strings

Open
#863 2 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@explosion3975 is already working on this.

Since Nov 26, 2026.

  • #866 by @explosion3975 — open

Assessment

This issue has not been assessed yet.

Description

Observed behavior

The five built-in cases for Metric Namespace Root (longest-common-prefix, LeetCode 14) all accept a solution that compares only the first and last strings in the input array. It never examines the strings between them.

def sharedLeadingText(strs):
    first, last = strs[0], strs[-1]
    i = 0
    while i < min(len(first), len(last)) and first[i] == last[i]:
        i += 1
    return first[:i]
Expected behavior

The judge should reject a solution that ignores a middle string. The contract requires the returned prefix to be shared by every string.

Proposed fix

Add ["flower", "dog", "flow"] with expected output "" as a built-in case. Append it after the existing cases so the variant's example reference keeps pointing to the same case.

Could you assign this issue to me?

Dominant language
Rust
Stars
236
Forks
153
Avg merge
1d 9h
Merged PRs (30d)
187

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sysprog21/codetrial

All issues in sysprog21/codetrial

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.