Problem1:
Problem Statement
You are given a task where in you have to sort the given doubly linked list.
Input Format
The rst line of the input is N,N is the number of elements in Linked List.
The second line of the input contains N inputs, elements in Linked List.
Output Format
Print the Linked List after sorting
PYTHON PROGRAM:
a=int(input())
b=list(map(int,input().split()))
print(*sorted(b),sep=' ')
*************************************************
Problem2:
Problem Statement:
Shawn is asked to check if the given doubly linked list is a palindrome or not.
Input Format :
The rst line of the input is N,N is the number of elements in Linked List.
The second line of the input contains N inputs, elements in Linked List.
Output Format:
Print 'Yes' if the Linked List is a palindrome, else print 'No
PYTHON PROGRAM:
a=int(input())
f=list(map(int,input().split()))
g=[]
for i in range(len(f)-1,-1,-1):
g.append(f[i])
if(g==f):
print("Yes")
else:
print("No")
****************************************************************
Post a Comment