@@ -0,0 +1,2069 @@
+//  Copyright 2016 The Sawdust Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A//     http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A//%0A%0A// Given an array nums, write a function to move all 0's to the end of it%0A// while maintaining the relative order of the non-zero elements.%0A// For example, given nums = %5B0, 1, 0, 3, 12%5D, after calling your function, nums should be %5B1, 3, 12, 0, 0%5D.%0A// Note:%0A// You must do this in-place without making a copy of the array.%0A// Minimize the total number of operations.%0A%0A// https://leetcode.com/problems/move-zeroes/%0A%0A// not find the fast one yet%0Apublic class Leetcode283MoveZeroes %7B%0A    public void moveZeroes(int%5B%5D nums) %7B%0A        int zeroIndex = -1;%0A        for (int i = 0; i %3C nums.length; i++) %7B%0A            int cur = nums%5Bi%5D;%0A%0A            if (cur == 0 && zeroIndex == -1) %7B%0A                zeroIndex = i;%0A                continue;%0A            %7D%0A%0A            if (cur != 0 && zeroIndex != -1) %7B%0A                //swap%0A                nums%5BzeroIndex%5D = cur;%0A                nums%5Bi%5D = 0;%0A                zeroIndex++;%0A            %7D%0A        %7D%0A    %7D%0A%0A    public void moveZeroes2(int%5B%5D nums) %7B%0A        for (int i = 0, j = 0; i %3C nums.length; i++) %7B%0A            if (nums%5Bi%5D != 0) %7B%0A                int temp = nums%5Bi%5D;%0A                nums%5Bi%5D = nums%5Bj%5D;%0A                nums%5Bj%5D = temp;%0A                j++;%0A            %7D%0A        %7D%0A    %7D%0A%0A    public void moveZeroes3(int%5B%5D nums) %7B%0A        int p = 0;%0A        for (int i : nums) %7B%0A            if (i != 0) %7B%0A                nums%5Bp++%5D = i;%0A            %7D%0A        %7D%0A        while (p %3C nums.length) nums%5Bp++%5D = 0;%0A    %7D%0A%7D

Add Leetcode283MoveZeroes