Home > Back-end >  Force 189 - rotating array problem solving buckled brush
Force 189 - rotating array problem solving buckled brush

Time:11-26

Beginning of # # # # contact force buckles and wanting to improve their programming ability, in the brush after some of the questions, finally today problems

I used on the local Vcode first write again on the power button to run again, this topic, I try this operation again, after I think of the three possible and correct output into the power button is showing me is not correct, but I use this error locally sample output is correct, please bosses told her little brother, this is why ah, baidu also can't find what's going on...
The figure below:



Another problem is the test cases show that exceed the time limit of

Thank you for your bosses first!!!!!!

CodePudding user response:

The third kind of algorithm has a problem, g=k - length, g may also be greater than the length
The second algorithm k> Length, nums. End () - k may have a problem
The first algorithm, k is very big, the for loop may timeout

The right thing to do, first k=k % length;//should be k=length just improved a circle back to the origin, the k is greater than the length when look at how much around the whole circle, the remainder is actually the rotation occurs
With the first or the second solution can

CodePudding user response:

Oh oh, really is, thanks for the advice of, just began to learn, not to be able to turn the==brain
  • Related