backtobackswe / backtobackswe-feedback

1 stars 0 forks source link

Nearest Repeated Entries In An Array #33

Open bryanchau11 opened 2 years ago

bryanchau11 commented 2 years ago

Back To Back SWE



Create a bug report to help us improve our content -



Your email registered on BackToBackSWE :

cktnhat1234@gmail.com

Category of the bug :

Description of the bug :

The IDE just keeps spinning and doesn't allow me to submit.

Code you used for Submit/Run operation :

import math 
class Solution:
    def distanceOfClosestRepeatedEntries(self, sentence):
        '''
        :type sentence: list of str
        :rtype: int
        '''
        dict = {}
        res = math.inf
        for i in range(len(sentence)):
            if sentence[i] not in dict:
                dict[sentence[i]] = i
            else:
                newDiff = i - dict[sentence[i]]
                res = min(res, newDiff)
                dict[sentence[i]] = i
        return res



Language used for code :

Python



Expected behavior :

It allows me to submit.

Screenshots :



Additional context :