Time flies while you're having fun, but then one day your bio says something about being a 30+ year veteran in software engineering. Still, I've not seen it all, let alone done it all (yet).
Your "shift then push" approach changes the positions of the values in the array, but not their order. Conceptually, (shift then push) * length gets you back were you started.
As the task asks you to "rearrange" the values, which I take to mean "change the order" of the values, and you are not changing the order, it would seem that this approach cannot work in the general case.
For example, in the case of
solver([3,5,7,1,6,8,2,4], 3, 13);
the return value is
[7,1,6,8,2,4,3,5]
This is clearly the input rotated 2 to the left, and the first slice [7, 1, 6] sums to 14 (when it should be <= 13).
(In the worst case, where no slice of the input sums <= q, your function will run forever).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Your "shift then push" approach changes the positions of the values in the array, but not their order. Conceptually, (shift then push) * length gets you back were you started.
As the task asks you to "rearrange" the values, which I take to mean "change the order" of the values, and you are not changing the order, it would seem that this approach cannot work in the general case.
For example, in the case of
solver([3,5,7,1,6,8,2,4], 3, 13);
the return value is
[7,1,6,8,2,4,3,5]
This is clearly the input rotated 2 to the left, and the first slice [7, 1, 6] sums to 14 (when it should be <= 13).
(In the worst case, where no slice of the input sums <= q, your function will run forever).