nuxy / leetcode-1431

Benchmark created on


Description

Kids With the Greatest Number of Candies

Setup

const kidsWithCandies = function(candies, extraCandies) {
  const arr = [];

  for (let i = 0; i < candies.length; i++) {
    const count1 = candies[i] + extraCandies;

    let greatest = count1;

    for (let j = 0; j < candies.length; j++) {
      const count2 = candies[j];

      if (count2 > greatest) {
        greatest = count2;
      }
    }

    arr.push((count1 === greatest));
  }

  return arr;
};

Test runner

Ready to run.

Testing in
TestOps/sec
Test 1
kidsWithCandies([2,3,5,1,3], 3); // [true,true,true,false,true]
ready
Test 2
kidsWithCandies([4,2,1,1,2], 1); // [true,false,false,false,false]
ready
Test 3
kidsWithCandies([12,1,12], 10); // [true,false,true]
ready

Revisions

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