Company: Nokia_7june
Difficulty: medium
Spell Fragmentation Decoder An ancient scroll carries one long unbroken string encodedString of lowercase letters. The scroll is really a sequence of magical words written with the gaps rubbed out, and you also hold a dictionary of dictionarySize known magical words. To decode the scroll you must cut encodedString into consecutive pieces so that every piece is a word from the dictionary and the pieces together use up the whole string — no letter may be skipped, no letter may be covered twice. A dictionary word may be reused as often as you like. Many decodings may be possible. Report the one with the largest number of pieces . If the string cannot be cut up this way at all, report 0 . Function Description Implement maxWordsDecrypted , which takes encodedString and the list dictionary and returns the maximum number of pieces in a valid decoding, or 0 when no valid decoding exists. Input Format The first line contains the string encodedString . The second line contains the integer dictio