I am trying this problem : http://www.spoj.com/problems/UCODES/
Approach : First assume any codeword(=S) to be the first part of the answer.Then since S has to be formed in >=2 ways ,there should be another codeword which is a prefix of S. So I try all other strings which are prefix of S, and take the minimum by applying recursion on the remaining part of S (as the same thing has to be calculated on the remaining part).
But this is getting WA .Can anybody verify if the approach is correct , or post any test cases ?
Code :: http://ideone.com/DAiXA1