8
votes
LeetCode 2. Add Two Numbers
Within the confines of Leetcode's requirements, this is about as straightforward a solution as can be hoped for. A few style suggestions have been pointed out by toolic.
The following code can be ...
6
votes
Accepted
LeetCode 2. Add Two Numbers
Naming
The PEP 8 style guide recommends
snake_case for function and variable names. I realize the LeetCode
site requires you to give the primary function those names, but you would
otherwise name the ...
4
votes
Memorise array and print number of occurrences
You do not need to store all numbers in arrays
You can immediately use the values from the input. So the first fallacy is:
...
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 ...
2
votes
LeetCode 22. Generate Parentheses (C++)
By default, std::stack uses std::deque as it's underlying container. However, this is just the default, and any container which ...
1
vote
Advent of Code 2023 day 1: Trebuchet (Part 1)
There is an opportunity in modern C++ to offload the processing of each line using std::views::istream.
...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
programming-challenge × 3404python × 1048
algorithm × 666
performance × 655
java × 636
time-limit-exceeded × 518
c++ × 493
python-3.x × 449
beginner × 429
c# × 298
javascript × 289
strings × 217
primes × 184
c × 161
functional-programming × 109
array × 105
haskell × 101
python-2.x × 94
interview-questions × 93
dynamic-programming × 87
ruby × 78
recursion × 77
palindrome × 76
object-oriented × 74
combinatorics × 71