title

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
efan
window.solve = function(input) {
 var o = [],
     output = [];
 for (var i = 0; i < input.length; i++) {
  if (o.search(input[i]) !== false) {
   output.push(input[i]);
  }
  o.push(Math.abs(input[i]));
 }
 return output;
};
Array.prototype.search = function(value) {
 for (var i = 0; i < this.length; i++) {
  if (this[i] === value) {
   return i;
  }
 }
 return false;
}


var input = [-4, -3, -1, 1, 2, 4, 67];
solve(input);
ready
efan2
window.solve = function(input) {
 var o = [],
     output = [];
 for (var i = 0; i < input.length; i++) {
  if (o.search(input[i]) !== false) {
   output.push(input[i]);
  }
  o.push(Math.abs(input[i]));
 }
 return output;
};
Array.prototype.search = function(value) {
 for (var i = 0; i < this.length; i++) {
  if (this[i] === value) {
   return true;
  }
 }
 return false;
}


var input = [-4, -3, -1, 1, 2, 4, 67];
solve(input);
ready

Revisions

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