link to my solution: W string
Well see ur answer is correct, ie., the wstr function is working fine… with only one problem in main that u r detecting ‘\n’ for a next line… consider the last test case in input… according to ur program it is important that there must be a next line character, but the last case will not have it…
for this purpose I tested ur solution… do notice that for same input it is responding differently as first I didnt gave a newline character and then I gave newline character…
here is a correct implementation, which uses string input of character array, though I still felt some need of correction, so I improved further and removed unnecessary use of res array in main function…, see much improved implementation…
And also look at the constraints string length is 1 ≤ |S| ≤ 10000 (10^4) so u should take str length 10001 one extra becuz of null char.
correctly pointed… I forgot to mention that, though I corrected that in the last implementation…
you almost corrected everything dude . Gud job
Thanx devanshug. I had not been able to find this error on my own. I am new here and had never faced such an error. But now i have got it. Will keep in mind.
And yes chandan i will keep it too in mind from the next time. thanx