There own solutions are not working


#1

I tried this question by different tricks and guess what its not working.
I checked their given solutions!!— AND ITS NOT WORKING
THANKS FOR WASTING MY TIME


#2

Its working for C++ solution, I checked.
Please mention the language of the solution in which you think there is an issue.


#3

@kunalkhandelwal69992
I tried with my own solution in CPP and it worked. So there is no problem with qs.


#4

my solution is working


#5

yeah their solution doesn’t work but you can understand it and correct it fully.
Below is the one that works after adding two little if statements in the code.
def solve(self, A):
s=’’
temp=’’
i=len(A)-1
while i>-1:
if A[i]!=’ ‘:
temp+=A[i]
i-=1
if A[i]==’ ‘:
s=s+temp[::-1]
if temp!=’’:
s += ’ ’
temp=’’
i-=1
s=s+temp[::-1]
if temp==’’:
s = s[:-1]
return s

The indentation is getting messed up while commenting, apologies!