- Notifications
You must be signed in to change notification settings - Fork2.4k
Closed
Description
Bug Report forhttps://neetcode.io/problems/palindromic-substrings
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
The code below was submitted on both neetcode.io and leetcode.com. It was accepted on neetcode.io, but rejected on leetcode.com, which made me realise I made a small mistake while writing my solution. Narrowed down the missing test case on neetcode.io to"abca"
, which is correctly marked as wrong answer when run as a test case, but not checked during submission.
classSolution:defcountSubstrings(self,s:str)->int:defcountPalindromes(i:int,j:int)->int:count=int(s[i]==s[j])# <-- mistake herewhilei-1inrange(len(s))andj+1inrange(len(s))ands[i-1]==s[j+1]:i,j=i-1,j+1count+=1returncounttotal=0foriinrange(len(s)):total+=countPalindromes(i,i)ifi>0:total+=countPalindromes(i-1,i)returntotal
Metadata
Metadata
Assignees
Labels
No labels