Itsy needs your help with her magic cards. Her magic cards grant her special spider-witch powers. Un…
Click here to read the complete problem statement.
If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.
m, n = map(int, input().split())
arr = []
for i in range(n):
arr.append(list(map(str, input().split())))
for item in arr:
if ord(item[0]) + 1 == ord(item[1]):
m -= 1
elif ord(item[0]) - 1 == ord(item[1]):
m -= 1
print(m)
@hjr265 Getting Wrong output at #3
Don’t know where am i doing it wrong, can you please point out the reason!
n,m = map(int, input().split())
dic = {}
l = []
for i in range(m):
a,b = input().split()
l.append(a+b)
dic[a] = dic[a]+1 if a in dic else 1
dic[b] = dic[b]+1 if b in dic else 1
s = [x for x,v in sorted(dic.items(),key = lambda itm:itm[1],reverse=True)]
w = []
for k in s:
for p in l:
if len(p)>1 and k in p:
l[l.index(p)] = p.replace(k, '')
w.append(k)
print(n-len(set(w)))