×

# help needed in hackerrank problem

 0 try to do it backwards. First convert the string into the encrypted code. Then just start from last and at every step you have two choices either to take the current digit only or (if possible i.e. <=26) then take the current and previous digit and corresponding merge it with appropraite position. We maintain a vector of string for each index which denotes 'What is the different string we can get if we start from current position'. So, let's suppose you are building the answer for position 'i' (means you have the answers for all the indexes 'j' : (i < j <= n-1)). So, at current place you have two choices i.e. either take current position digit only and form a string with the remaining digits (i.e. from [i+1, n-1]) (for doing that we have to just merge the current character with the vector of index 'j+1'). Or we can take next digit also and check it's possibility (i.e. <= 26) and at that time we have to just merge that character with the list of strings of index 'j+2'. And we have to just print the list of index '0'. And we are done! Don't forget to sort it before printing! answered 05 Apr '18, 08:35 2★pk301 627●10 accept rate: 16%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×349
×310
×181

question asked: 05 Apr '18, 00:33

question was seen: 167 times

last updated: 05 Apr '18, 08:35