Longest prefix suffix Infosys springboard coding question with solution Problem Statement : Given a non-empty sting instr containing only alphabets, print the length of the longest prefix in instr which is same as the suffix.The prefix and suffix should not be overlap in instr Print -1 if no prefix exists which is also the suffix without overlap. Do case-sensitive comparisons whenever necessary Positions starts from 1 Question : Code Solution : s=input() count=0 for i in range(len(s)//2,0,-1): if s[0:i]==s[len(s)-i:]: print(len(s[0:i])) break Categories: Coding QuestionSpringboard Tags: #python #springboard 0 Comments Leave a Reply Cancel replyYour email address will not be published. Required fields are marked * Name Email Website What's on your mind? Save my name, email, and website in this browser for the next time I comment. Δ
0 Comments