+ 4
You are using uninitialized string.. Use string NewStr=word; else use append method for adding to string..
9th Jun 2022, 12:19 PM
Jayakrishna šŸ‡®šŸ‡³
+ 2
Manav Roy at line 8, Frequency = 0 not {} // use initialized string, Note: make sure that length of NewStr should be equal to the word because you are encoding the word or else fill the NewStr with anything upto the length of string word string NewStr = word; // NewStr = "00000" šŸ‘ˆšŸ‘ˆšŸ‘ˆ both will work https://code.sololearn.com/cDjag44DFkqn/?ref=app
9th Jun 2022, 3:56 PM
NonStop CODING
NonStop CODING - avatar
+ 2
Your string NewStr{} is zero length so NewStr[i] will access to uninitialized location which will lead undefined behaviour.. Instead try : NewStr += ')' Your are reassigning all values of "word" characters, so you need string of length word.length ; So NewStr = word will define string with desired length.... Hope it clears...
9th Jun 2022, 5:17 PM
Jayakrishna šŸ‡®šŸ‡³