World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITian's, only for AI Learners.
Given two string arrays str1 and str2, return true if the two arrays represent the same string, and false otherwise.
A string is represented by an array if the array elements concatenated in order forms the string.
Following function check If Two String Arrays are Equivalent or not?
# two for loops: redundant def string_equivalent(str1,str2): new_1 = "" # data type has to be a string new_2 = "" for i in str1: new_1+=i for j in str2: new_2+=j return new_1==new_2 # test case str1 = ["xy", "z"] str2 = ["x", "yz"] string_equivalent(str1,str2)