Ordering of strings
Easy Accuracy: 72.37% Submissions: 355 Points: 2

You will be given N number of strings. You have to find the lexicographically smallest string and the lexicographically largest string among these strings.

Example 1:

Input:
N = 3
strings = a , ab , abc
Output: a abc
Explanation: Lexicographically smallest is
"a" and lexicographically largest is
"abc".

 

Example 2:

Input:
N = 2
strings = abc , abc
Output: abc abc
Explanation: Lexicographically smallest is
"abc" and lexicographically largest is
"abc"

 

Your Task:  
You dont need to read input or print anything. Complete the function orderString​() which takes a 2d character array and an integer N as input parameter and returns an array of size 2 where first value should be lexicographically smallest string and second value should be lexicographically largest string.

 

Expected Time Complexity: O(N* max of all string length ).
Expected Auxiliary Space: O(1).

 

Constraints:
1 <= N , length of each string <= 103

 

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Ordering of strings

Output Window