Check if a string can be split into two substrings such that one substring is a substring of the other | Function to check if a can be divided into two substrings such that one subis subof the other ; Store the last character of S ; Traverse the characters at indices [ 0 , N - 2 ] ; Check if the current character is equal to the last character ; If true , set f = 1 ; Break out of the loop ; Driver Code ; Given string , S ; Store the size of S ; Function Call
def splitString ( S , N ) : NEW_LINE INDENT c = S [ N - 1 ] NEW_LINE f = 0 NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT if ( S [ i ] == c ) : NEW_LINE INDENT f = 1 NEW_LINE break NEW_LINE DEDENT DEDENT if ( f ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT S = " abcdab " NEW_LINE N = len ( S ) NEW_LINE splitString ( S , N ) NEW_LINE DEDENT