{"id":"e622e66c-f6d9-4e34-a1b1-4626f9a0ef17","name":"Alien Dictionary","description":"You are given a list of strings from the alien language's dictionary, where the strings in words are sorted lexicographically by the rules of this new language.\r\nReturn a string of the unique letters in the new alien language sorted in lexicographically increasing order by the new language's rules. If there is no solution, return \"\". If there are multiple solutions, return any of them.\r\n","inputFormat":"First line contains one integer N. \r\nNext line contains n Strings.","outputFormat":"Return a string of the unique letters in the new alien language sorted in lexicographically increasing order.","constraints":"1 &lt;= number of words &lt;= 100\r\n1 &lt;= length of each word &lt;= 100\r\nword consists of only lowercase English letters","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nstring alienOrder(vector<string>& words) {\n // write your code here\n}\nint main() { \n int n;\n cin>>n;\n vector<string> words(n);\n for(int i = 0; i < n; i++){\n cin>>words[i];\n }\n \n cout<<alienOrder(words)<<endl;\n}"},"java":{"code":"import java.io.BufferedReader;\r\nimport java.io.IOException;\r\nimport java.io.InputStreamReader;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws NumberFormatException, IOException {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n\r\n int n = Integer.parseInt(br.readLine());\r\n\r\n String[] words = br.readLine().split(\" \");\r\n\r\n System.out.println(alienOrder(words));\r\n }\r\n\r\n public static String alienOrder(String[] words) {\r\n\r\n }\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"5\r\nwrt wrf er ett rftt","sampleOutput":"wertf\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"7e07fddf-83bd-421e-848f-118f1f29541c","name":"Graphs For Intermediate","slug":"graphs-for-intermediate-493","type":0},{"id":"4bea0121-95c8-4457-ba20-4296ae672e0f","name":"Alien Dictionary","slug":"alien-dictionary","type":1}],"next":{"id":"b3995831-c95f-4aa8-8a80-ec2450d9545a","name":"Alien Dictionary Medium MCQ","type":0,"slug":"alien-dictionary-medium-mcq"},"prev":{"id":"cffe1667-2069-4b32-b859-8b6177e16249","name":"Pepcoder And Reversing","type":3,"slug":"pepcoder-and-reversing"}}}

Alien Dictionary

You are given a list of strings from the alien language's dictionary, where the strings in words are sorted lexicographically by the rules of this new language. Return a string of the unique letters in the new alien language sorted in lexicographically increasing order by the new language's rules. If there is no solution, return "". If there are multiple solutions, return any of them.

{"id":"e622e66c-f6d9-4e34-a1b1-4626f9a0ef17","name":"Alien Dictionary","description":"You are given a list of strings from the alien language's dictionary, where the strings in words are sorted lexicographically by the rules of this new language.\r\nReturn a string of the unique letters in the new alien language sorted in lexicographically increasing order by the new language's rules. If there is no solution, return \"\". If there are multiple solutions, return any of them.\r\n","inputFormat":"First line contains one integer N. \r\nNext line contains n Strings.","outputFormat":"Return a string of the unique letters in the new alien language sorted in lexicographically increasing order.","constraints":"1 &lt;= number of words &lt;= 100\r\n1 &lt;= length of each word &lt;= 100\r\nword consists of only lowercase English letters","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nstring alienOrder(vector<string>& words) {\n // write your code here\n}\nint main() { \n int n;\n cin>>n;\n vector<string> words(n);\n for(int i = 0; i < n; i++){\n cin>>words[i];\n }\n \n cout<<alienOrder(words)<<endl;\n}"},"java":{"code":"import java.io.BufferedReader;\r\nimport java.io.IOException;\r\nimport java.io.InputStreamReader;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws NumberFormatException, IOException {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n\r\n int n = Integer.parseInt(br.readLine());\r\n\r\n String[] words = br.readLine().split(\" \");\r\n\r\n System.out.println(alienOrder(words));\r\n }\r\n\r\n public static String alienOrder(String[] words) {\r\n\r\n }\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"5\r\nwrt wrf er ett rftt","sampleOutput":"wertf\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"7e07fddf-83bd-421e-848f-118f1f29541c","name":"Graphs For Intermediate","slug":"graphs-for-intermediate-493","type":0},{"id":"4bea0121-95c8-4457-ba20-4296ae672e0f","name":"Alien Dictionary","slug":"alien-dictionary","type":1}],"next":{"id":"b3995831-c95f-4aa8-8a80-ec2450d9545a","name":"Alien Dictionary Medium MCQ","type":0,"slug":"alien-dictionary-medium-mcq"},"prev":{"id":"cffe1667-2069-4b32-b859-8b6177e16249","name":"Pepcoder And Reversing","type":3,"slug":"pepcoder-and-reversing"}}}
plane

Editor


Loading...

Alien Dictionary

easy

You are given a list of strings from the alien language's dictionary, where the strings in words are sorted lexicographically by the rules of this new language. Return a string of the unique letters in the new alien language sorted in lexicographically increasing order by the new language's rules. If there is no solution, return "". If there are multiple solutions, return any of them.

Constraints

1 <= number of words <= 100 1 <= length of each word <= 100 word consists of only lowercase English letters

Format

Input

First line contains one integer N. Next line contains n Strings.

Output

Return a string of the unique letters in the new alien language sorted in lexicographically increasing order.

Example

Sample Input

5 wrt wrf er ett rftt

Sample Output

wertf

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode