nuxy / leetcode-283

Benchmark created on


Description

Move Zeroes

Setup

const moveZeroes = function(nums) {
  for (let i = 0; i < nums.length; i++) {
    if (nums[i] === 0) {
      nums.splice(i, 1);
      nums.push(0);
    }
  }
};

const nums1 = [0,1,0,3,12];
const nums2 = [0];

Test runner

Ready to run.

Testing in
TestOps/sec
Test 1
moveZeroes(nums1); // nums1 = [1,3,12,0,0]
ready
Test 2
moveZeroes(nums2); // nums2 = [0]
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.