my algorithm gives 7 steps and is considered wrong
is this path wrong?
Your first step is wrong. We are asked to pass the dress at the same time. Since the 2nd washing machine has no dress in your first move, you cannot move dress from 2nd to 1st after the 2nd receiving one dress from 3rd, but counting them at the same move.
@zyjdxtc Your first step is incorrect. A dress can be moved to an adjacent washing machine only.
But the first step is exactly the same as the example in problem description.
Input: [0,0,2,2] Output: 1 Explanation: 1st move: --> 0 0 <-- 2 2 => 1 1 1 1 |_ _ _ _ _ _ _ _ _ _ _ _|
Truly sorry for the misunderstanding and trouble.
The problem description has been changed at the beginning of the contest (around 2 minutes),
Though we have added a notice during the contest, it seems that your example and answer belongs to the original-wrong problem description.
Truly sorry for the trouble, we'll make the notice more real-time & Ajax in the future.
@dettier now I see the machines has been changed into a line ... I tried to solve it as a circle for the as the cache problem
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.