Ad
  • Custom User Avatar

    Learn to match! The code works in O(n), this is a naive solution. If the input data value is greater than 10 ^10, the code will work very slowly (or even not at all). Using the sum of the arithmetic progression gives a constant time complexity. I don't understand why so many people marked such a decision as "the best".