Skip to main content

New answers tagged

3 votes

Hackerearth: Counting numbers in an array that are divisible by any 2 numbers

Always assume that coding challenge websites will give you worst case scenarios to test your code. They won't test your code with small arrays of small numbers. They'll give you large arrays with huge ...
Chris's user avatar
  • 6,126
1 vote

Hackerearth: Counting numbers in an array that are divisible by any 2 numbers

Portability I realize this question was posted many years ago when Python version 2.x was prevalent, but now that it is deprecated, consider porting to 3.x. To do so, it is necessary to add ...
toolic's user avatar
  • 16.4k
6 votes

LeetCode 3542: Minimum Operations to Convert All Elements to Zero

missing docstring def split_non_zeros(self, nums): This is terrible. The identifier is not bad, as far as it goes. But we need to know what the function ...
J_H's user avatar
  • 43.3k
6 votes
Accepted

LeetCode 3542: Minimum Operations to Convert All Elements to Zero

Style First off, let's address a couple of style issues. Looping over indices of a list is better achieved with enumerate than with ...
Chris's user avatar
  • 6,126
3 votes

LeetCode 3542: Minimum Operations to Convert All Elements to Zero

Simpler Here are some general coding style suggestions. The following: counter = counter + 1 can be simplified using the special assignment operator: ...
toolic's user avatar
  • 16.4k

Top 50 recent answers are included