Mirrored Tag Segment accepts reversed-copy common-substring solutions
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
Observed behavior
In Mirrored Tag Segment (longest-palindromic-substring, LeetCode 5), the Python solution below passes all five built-in tests. It takes the longest common substring of the read and its reversed copy and never checks that the result reads the same both ways. The brief says the scanner reads a tag forwards and backwards, so comparing the two directions is the first thing a candidate will try.
class Solution:
def longestMirroredRun(self, s: str) -> str:
r = s[::-1]
n = len(s)
best_len, best_end = 0, 0
prev = [0] * (n + 1)
for i in range(1, n + 1):
cur = [0] * (n + 1)
for j in range(1, n + 1):
if s[i - 1] == r[j - 1]:
cur[j] = prev[j - 1] + 1
if cur[j] > best_len:
best_len, best_end = cur[j], i
prev = cur
return s[best_end - best_len:best_end]
All five current cases (babad, cbbd, a, ac, racecar) happen to have a palindromic longest common substring with their reverse, so the palindrome checker in web/lib.js accepts the shortcut 5/5. The LeetCode editorial for problem 5 warns about this approach: it breaks when a reversed copy of a non-palindromic substring appears elsewhere in the string.
Expected behavior
At least one built-in case contains a reversed copy of a non-palindromic substring, so the common-substring shortcut returns a stretch that is not mirrored and fails. A correct solution still passes every case.
Reproduction
- Run CodeTrial at the revision below and open Mirrored Tag Segment with Python.
- Paste the solution above and run the tests. All five built-in cases pass.
- Under "Add a case", enter
["abacdfgdcaba"]as the input and"aba"as the expected value, then run again. The new case fails: the solution returnsabacd(its prefix, echoed backwards at the end of the read), which has length 5 and is not mirrored, while the longest mirrored stretch isabawith length 3.
Any common substring of length 4 or more must fail here, because the longest palindrome in abacdfgdcaba has length 3; the checker rejects the wrong answer on both length and palindromicity, so the case holds regardless of which length-5 candidate (abacd or dcaba) an implementation prefers.
CodeTrial version
codetrial 0.1.0 (5c1fdce), built from source at current main.
Environment
- OS: Windows 11 host with Ubuntu 24.04 under WSL2
- Browser: Chrome
- Language: Python
- Interview loop: Coding
- Problem: Mirrored Tag Segment (Longest Palindromic Substring, LeetCode 5)
- REACTO or STAR step: Test
- Reconnect: Not applicable; this report concerns test-case coverage
Sanitized evidence
| Solution | Existing 5 cases | With abacdfgdcaba added |
|---|---|---|
| Common-substring shortcut above | 5/5 | 5/6 (returns abacd) |
| Centre-expansion reference | 5/5 | 6/6 |
The table comes from running both solutions against the cases in problem-bank/judges.json under the palindrome checker's rules (string, equal length, substring of the input, mirrored). The screenshots below show the browser reproduction at 5c1fdce: the solution above passes all five built-in cases, and the added case fails with got "abacd" while the interviewer, seeing the green run, asks about complexity as if the solution were correct.
Public data confirmation
- I removed credentials, session tokens, candidate recordings, and personal interview content from this public report.
Proposed scope
I read docs/adding-a-problem.md. I would add ["abacdfgdcaba"] with expected "aba" to problem-bank/judges.json under a label that describes the read rather than the shortcut, and regenerate the derived files. As the stock III test in tests/browser/compiler-explorer.test.js does, the regression would run the common-substring shortcut against every case and assert a centre-expansion reference passes all of them while the shortcut fails the added one, so a later edit to a case cannot quietly let it back in. Could you assign this to me?
- 主要语言
- Rust
- 星标
- 236
- 派生
- 153
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 187
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sysprog21/codetrial 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 70/100
维护者通常 1 天内回复
-
Unify Java harness validation error messages可能已有人在做 @weichieh0204 今天认领。 未关闭
sysprog21/codetrial#872 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Inferred void class operations are never checked against the starter's return type可能已有人在做 @papaya0112 今天认领。 未关闭
sysprog21/codetrial#871 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Edge Thumbnail Store accepts a store that does not refresh a key on overwrite可能已有人在做 @BOBOGUAGUA428 今天认领。 未关闭
sysprog21/codetrial#869 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 sysprog21/codetrial 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
CyberTimon/RapidRAW#2303 ·
维护者通常 1 天内回复
-
[bug] NSIS installer reads its flags from $CMDLINE, so an unquoted forward-slash path (e.g. C:/Projects/...) triggers passive mode and skips the licence page可能已有人在做 @YusufMntm 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
tauri-apps/tauri#16660 · 1 条评论 ·
维护者通常 1 天内回复
-
needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
manaflow-ai/cmux#59692 ·
维护者通常 1 天内回复
-
Retire stale Python-parity labels in Rust ingress and auth tests可能已有人在做 @github-actions 今天认领。 未关闭factory factory:building factory:unowned ralph-status:in-progress via:opencode-free/hy4-flash-free
难度 2/5 1-3 小时 新手友好度 82/100
JoshCLWren/comic-pile#5874 · 2 条评论 ·
维护者通常 1 天内回复
-
status:ready unit
难度 2/5 1-3 小时 新手友好度 75/100
nonagenticai/conveyor#787 ·
维护者通常 1 天内回复