• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
August 23, 2024 |250 Views

PROBLEM OF THE DAY : 22/08/2024 | Alien Dictionary

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Graph but also build up problem-solving skills.

YGiven a sorted dictionary of an alien language having N words and k starting alphabets of standard dictionary. Find the order of characters in the alien language.
Note: Many orders may be possible for a particular test case, thus you may return any valid order and output will be 1 if the order of string returned by the function is correct else 0 denoting incorrect string returned.
 

Examples :

Input:  N = 5, K = 4, dict = {"baa","abcd","abca","cab","cad"} Output: 1 Explanation: Here order of characters is 'b', 'd', 'a', 'c' Note that words are sorted and in the given language "baa" comes before "abcd", therefore 'b' is before 'a' in output. Similarly we can find other orders.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/alien-dictionary/1