In preparation for the exam, I encountered the following problem:
Imagine the alphabet of words. Example:
a ==> 1 b ==> 2 c ==> 3 ... z ==> 26 ab ==> 27 ac ==> 28 ... az ==> 51 bc ==> 52 and so on.
The sequence of characters should only be in ascending order (i.e., "ab" is valid, but "ba" is not).
Question For any word, type its index if it is valid and 0 if not.
Input Output ab 27 ba 0 aez 441
Any pointers on how to solve this problem would be appreciated.
algorithm combinations combinatorics
Karan Kalra
source share