Little Jill jumbled up the order of the letters in our dictionary. Now, Jack uses this list to find the smallest lexicographical string that can be made out of this new order. Can you help him?
You are given a string P that denotes the new order of letters in the English dictionary.
You need to print the smallest lexicographic string made from the given string S.
Answers
Answer:
Unseen passage
Explanation:no
Answer:
Answer:
import java . util . *;
class dictionary
{
public static void main(String args[])
{
Scanner sc=new Scanner(System . in);
System . out . println();
int t=sc . nextInt();
while(t!=0)
{
System . out . println("Enter the sequence of the characters");
String p=sc . nextLine();
System . out . println();
String s=sc . nextLine();
for(int i=0;i<p . length();i++)
{
for(int j=0;j<s . length();j++)
{
if(p . charAt(i)==s . charAt(j))
{
System . out . println(s . charAt(j));
}
}
}
t--;
}
}
}