i scored 50% and getting partail solved can anyone tell me whats wrong n my solution
my logic is using 2 pointer consider window of k .
this is my solution
Well, what is wrong? Is it WA, TLE, RE, or something else?
2 Likes
Your mistake is on line 17. Re-read the problem’s constraints.
2 Likes
hello sir i am getting AC i change int fre[k+1] = {0}; but i am getting difference only (fre(n) i get that n take to much memory. can you explain me
1≤N≤105
2≤K≤105
i thing because of if n= 1 and k ==3 or more than it will not work .please correct me if i am saying wrong
DSA week 2 Q4 Compilers and parsers. I don’t get what wrong I did.
for i in range(int(input())):
s = input()
a = 0
b = 0
c = 0
if(s[0] == '>'):
a = 0
else:
for i in s:
if(i == '<'):
b += 1
else:
c += 1
if(b == c):
a = b + c
else:
d = min(b, c)
a = 2*d
print(a)
Please help.
this seems to be wrong what if <<<> is not valid
for i in range(int(input())):
s = input()
a = 0
b = 0
c = 0
d = 0
e = 0
g = 0
if(s[0] == '>'):
a = 0
else:
for i in range(len(s)):
if(s[i] == '<'):
b += 1
else:
c += 1
if(b == c):
a = b + c
elif(b > c):
for i in range(len(s)):
if(s[i] == '>'):
d = i
break
for i in range(d, len(s)):
if(s[i] == '>'):
e += 1
for i in range(d+1):
if(s[i] == '<'):
g += 1
if(e == g):
a = e+g
else:
a = 0
else:
#d = min(b, c)
a = 2*b
print(a)
Still not going
Help me in ZC012001 matched brackets
n = int(input())
a = list(map(int, input().split()))
b = []
c = 0
d = []
e = []
g = []
for i in range(len(a)):
if(a[i] == 1):
b.append(a[i])
c += 1
else:
if(len(b) == 0):
break
else:
d.append(len(b))
b.pop()
c -= 1
g.append(i)
if(len(b) == 0):
e.append(i+1)
#print(b)
#print(d)
#print(e)
#print(g)
h = max(d)
for i in range(len(d)):
if(d[i] == h):
j = i
break
k = g[j]
m = 0
for i in range(len(e)-1):
if(m < abs(e[i+1] - e[i])):
m = abs(e[i+1] - e[i])
p = e[i] + 1
print(h, k, m, p)
Ok sir.