Book 1-on-1 live assistance from the navigation menu
I'm just a message away. Let's solve it together. 👨💻
DPWORLD Coding Question – Solved
7 Live
There are two neighbours and they both have plates with their names written on them. Now, neighbour B wants to use neighbour A's plate because he lost his. So, B needs to make a nickname for himself. B has to remove the minimum number of consecutive characters from his name in such a way that it becomes a subsequence of A's plate. There is a possibility that he may have to remove all the characters to make the name empty. The name only contains lowercase letters of the English alphabet.
You need to return the name to be written on B's plate which is present as a subsequence in A's plate. If there is no such subsequence, return "*-".
Input Format:
- The first line contains the name of neighbour A.
- The second line contains the name of neighbour B.
Constraints:
- 1 <= len(a), len(b) <= 10^6
Output Format:
- Return the name to be written on B's plate which is present as a subsequence in A's plate.
Evaluation Parameters
Sample Input:
maria
arizona
Sample Output:
aria
Explanation:
If you remove the string 'zon' from arizona, the name on B's plate will be aria, and it is a subsequence of A's plate.