The program must accept N string values and sort them. Then the program must print the first and the last string values.
Input :
5
lion tiger elephant monkey leopard
Output :
elephant
tiger
Explanation:
Here N = 5.
After sorting the 5 string values, the string values become elephant leopard lion monkey tiger
Here, the first and the last string values are elephant and tiger.
Hence the output is
elephant
tiger
Here are the various methods and logic.
Python :





C :

Java :

Leave a Reply