- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to check whether two string arrays are equivalent or not in Python
Suppose we have two string type arrays word1 and word2, we have to check whether the two arrays represent the same string or not. We can say a string can be represented by an array if the elements in that array are concatenated in order forms the string.
So, if the input is like word1 = ["ko", "lka", "ta"] word2 = ["k", "olk", "at", "a"], then the output will be True as both are forming "kolkata".
To solve this, we will follow these steps −
s1:= blank string, s2:= blank string
for each string i in word1, do
s1 := s1 concatenate i
for each string i in word2, do
s2 := s2 + i
return true if s1 is same as s2, otherwise false
Example (Python)
Let us see the following implementation to get better understanding −
def solve(word1, word2): s1='' s2='' for i in word1: s1+=i for i in word2: s2+=i return (s1==s2) word1 = ["ko", "lka", "ta"] word2 = ["k", "olk", "at", "a"] print(solve(word1, word2))
Input
["ko", "lka", "ta"], ["k", "olk", "at", "a"]
Output
True
- Related Articles
- Check whether two strings are equivalent or not according to given condition in Python
- Program to check whether two sentences are similar or not in Python
- Program to check string is palindrome or not with equivalent pairs in Python
- Program to check whether parentheses are balanced or not in Python
- Program to check whether leaves sequences are same of two leaves or not in python
- Python program to check whether a given string is Heterogram or not
- Program to check two parts of a string are palindrome or not in Python
- Program to check whether final string can be formed using other two strings or not in Python
- Program to check whether elements frequencies are even or not in Python
- C# program to check whether two sequences are the same or not
- Java Program to check whether two Strings are an anagram or not.
- Python Program to Check Whether a String is a Palindrome or not Using Recursion
- Program to check whether we can convert string in K moves or not using Python
- C++ program to check whether given string is bad or not
- Program to check whether all leaves are at same level or not in Python

Advertisements