0
What is the problem with this code?
In this code i am getting an output one but not the desired output https://code.sololearn.com/cJ9OU30sXSVL
5 ответов
+ 2
I haven't tried to run the code yet, but can you describe the problem more descriptively. Idk if I can help, but maybe I can try something if I can understand the situation better.
+ 2
Abhishek Dimri
You included <vector> header but you are using array, why though?
I'm not sure but, does the requirement say that the values must be rearranged in-place (directly in the original container)? are we allowed to create new array or std::vector which contains the values in such arrangement?
I think I have an idea if we were allowed to use another container to store the values in new arrangement. We can create a new container in the `arrange` function, and fill it up in such manner.
+ 1
Ipang There is a problem in Geeksforgeeks name Rearrange Alternately some thing like that and rest is written on the documentation section of the code
+ 1
Ipang no we are not allowed to use another array because space complexity given is O(1)
+ 1
Abhishek Dimri
In that case, things get a bit more complicated.
I'll post back here if I get an idea how to work it out. In the meantime I hope someone more capable could come up with something.