We have given four strings, w, x, y, and z.
We are allowed to change any of the four given strings to any one of their permutations respectively.
So we want to get a permutation of each of fours strings such that after inserting them in a trie number of nodes in trie is minimum.
Test Case:
w = "abac"
x = "bac"
y = "cab"
z = "acb"
// If we permute them to
w = "abca"
x = "abc"
y = "abc"
z = "abc"
// then the trie will have only four nodes.Can anyone help me out with the correct approach.