यहां दो लिस्ट्स दी गई हैं। हमारा कार्य चेक करना और पता लगाना है कि क्या दो दी गई लिस्ट्स सर्कुलरली आइडेंटिकल हैं या नहीं।
उदाहरण
Input: A = [100, 100, 10, 10, 100] B = [100, 100, 100, 10, 10] Output: True
व्याख्या
सत्य क्योंकि जब लिस्ट में ये एलिमेंट्स सर्कुलरली रोटेट होंगे तो वे दूसरी दी गई लिस्ट के समान होंगे।
एल्गोरिदम
चरण 1: पहली और दूसरी लिस्ट बनाएं। चरण 2: फिर लिस्ट्स को मैप में कन्वर्ट करें। चरण 3: join() मेथड का उपयोग लिस्ट ऑब्जेक्ट्स को स्ट्रिंग में कन्वर्ट करने के लिए किया जाता है। चरण 4: लिस्ट A को डबल करें और मैप में कन्वर्ट करें। चरण 5: दो लिस्ट्स की तुलना करें। यदि परिणाम सत्य है तो दो लिस्ट्स सर्कुलरली आइडेंटिकल हैं और यदि फाल्स लौटाता है तो वे सर्कुलरली नॉन-आइडेंटिकल हैं।
उदाहरण कोड
# पायथन प्रोग्राम: चेक करने और वेरिफाई करने के लिए कि दो लिस्ट्स सर्कुलरली आइडेंटिकल हैं या नहीं
A = list()
n = int(input("Enter the size of the First List ::"))
print("Enter the Element of First List ::")
for i in range(int(n)):
k = int(input(""))
A.append(k)
B = list()
n1 = int(input("Enter the size of the Second List ::"))
print("Enter the Element of the Second List ::")
for i in range(int(n1)):
k = int(input(""))
B.append(k)
C = list()
n3 = int(input("Enter the size of the Third List ::"))
print("Enter the Element of the Third List ::")
for i in range(int(n3)):
k = int(input(""))
C.append(k)
print("Compare First List and Second List ::>")
print(' '.join(map(str, B)) in ' '.join(map(str, A * 2)))
print("Compare Second List and Third List ::>")
print(' '.join(map(str, C)) in ' '.join(map(str, A * 2)))आउटपुट
Enter the size of the First List :: 5 Enter the Element of First List :: 10 10 0 0 10 Enter the size of the Second List :: 5 Enter the Element of the Second List :: 10 10 10 0 0 Enter the size of the Third List :: 5 Enter the Element of the Third List :: 1 10 10 0 0 Compare First List and Second List ::> True Compare Second List and Third List ::> False