Metric Namespace Root judge accepts solutions that ignore middle strings

Đang mở
#863 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@explosion3975 đang làm issue này rồi.

Từ ngày 26/11/2026.

  • #866 của @explosion3975 — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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?

Ngôn ngữ chính
Rust
Star
236
Fork
153
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
187

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của sysprog21/codetrial

Tất cả issue của sysprog21/codetrial

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.