Extra Character [AtCoder]

HyunMin Yang·2023년 1월 4일
1
post-thumbnail

Problem


Method

1) Get the input of two similar strings, S and T, in separate lines
2) Make a variable: 'cnt', for counting the location of both string
3) Use a For loop in the range of length of S, to see when S[i] is different from T[i]
4) When S[i] is different from T[i], break, and print the counting variable: 'cnt'
5) If not, add 1 to the counting variable: 'cnt', and repeat this for the rest of the range


Code

S = input()
T = input()
cnt = 1
 
for i in range(len(S)):
        if S[i] != T[i]:
            break
        else:
            cnt += 1
print(cnt)

Results


profile
Hello World!

0개의 댓글