Guys my code is failing in chef and string though all sample test cases are passing and a small change corrects my code i’m not getting
link to my solution is:
plz need ur help urgently
@cubefreak777 @saumyaparikh @shubhamskk @everule1
line 27: s = temp needs to be moved out of the for loop…
how it will effect the code
it will be assigned every time but at last s will be equals to temp only.
though after this the code is working but i am not getting the logic behind this
@cubefreak777 @everule1 @cub123 help
s =temp; should be written after the for loop because… you can not change s before it is assigned into s.
You could use a better approach… which is not iterative
@anon15316785 can u explain the logic behind ur code why u have applied only R twice???
R is a function to perform left shift twice(although it should be named as L).
left shift includes adding first letter at the end and removing the first letter from beginning.
you are doing lshift twice and then ur comparing it with original string
but in the given question we have to apply right shift and left shift both and the compare with each other…
i am not getting this…
see if right shift of a string is equal to left shift, then shift it any way twice it should result in the same string
apply R both sides…
if you apply L both sides…
Hope you’d get it.