CHEFRECP showing Wrong Answer

My code:
Please can someone point out my mistake? My approach is first I check for contiguous subarray using bool type visited array & then check for distinct frequency using map. Its showing correct output for given test cases but not accepted. :frowning:

Consider this case:

1000 500 500

Your are declearing the vis array with number of disticnt element in the input but accesing the values of the array. For this case, vis array has size 2 but you accessing vis[1000] and vis[500].

1 Like

My code is giving “YES” for this. There are 3 elements that you’ve passed in the input of array.

Oops sorry bro, i got my mistake now. Such a stupid mistake I’ve done. Thankyouuu . :slight_smile:

1 Like


Please tell me where i am wrong

from itertools import groupby
for i in range(int(input())):
    n = int(input())
    c = 0
    a = list(map(int, input().split()))
    g = sorted(a)
    b = [len(list(group)) for key, group in groupby(a)]
    h = [len(list(group)) for key, group in groupby(g)]
    b = sorted(b)
    h = sorted(h)
    if(b == h):
        #b = sorted(b)
        d = [len(list(group)) for key, group in groupby(b)]
        #for i in range(len(b)-1):
     #       if(b[i] == b[i+1]):
      #          c = 0
           # else:
        #     c = 1
        for i in d:
            if(i > 1):
                c = 1
        if(c == 1):