Header Ad

HackerEarth Lexical Analyzer problem solution

In this HackerEarth Lexical Analyzer problem solution Alex has recently decided to learn about how to design compilers. As a first step he needs to find the number of different variables that are present in the given code.

So Alex will be provided N statements each of which will be terminated by a semicolon(;). Now Alex needs to find the number of different variable names that are being present in the given statement. Any string which is present before the assignment operator denotes to a variable name.


HackerEarth Lexical Analyzer problem solution


HackerEarth Lexical Analyzer problem solution.

k=int(input().strip())

l=[]

p=set()

for _ inrange(k):

s=input().strip()

for i in s.split("="):

l.append(i)

p.add(l[0])

l=[]

print(len(p))

Post a Comment

0 Comments