4 ms·
I have a hard time thinking of a coding interview where this would be more useful than, say, reading a Python tutorial. It feels a bit dated. 1) it should ment
by eesmith 4y ago
I have a hard time thinking of a coding interview where this would be more useful than, say, reading a Python tutorial.
It feels a bit dated. 1) it should mention dataclasses instead of namedtuple - the latter has almost no place in modern Python; 2) there's no need to mention Python 3.5, 3) the OrderedDict example is the default for dict since 3.7 formalized what was already present in 3.6.
The following is not correct:
>>> 2 ** 3 # Equivalent to `pow(2, 3)`
The first returns the integer 8, the second returns the float 8.0.
The emphasis on "pseudo max-int" and "pseudo min-int", as in the following:
float('-inf') # Pseudo min-int
makes little sense. These are float values that can be used to compare as smaller-than or larger-than any integer value, but they are not "pseudo" and not "int".
>>> s.add(1) # Duplicate elements are not allowed per definition
>>> s
{1, 2}
>>> s.add('a') # We can mix types
>>> s
{1, 2, 'a'}
Don't teach mixing types in a set without explaining what "duplicate elements" means. Two objects of different types may still be duplicates, and two seemingly duplicate elements of the same type may be different:
>>> s = {1}
>>> s.add(1.0)
>>> s
{1}
>>> from fractions import Fraction
>>> s.add(Fraction(1, 1))
>>> s
{1}
>>> s.add(math.nan)
>>> s
{1, nan}
>>> s.add(float("nan"))
>>> s
{1, nan, nan}
- Pessimist5318 4y agoThanks for the useful comments. I will surely fix it based on them. It's more like a very basic reference for solving FAANG problems.
- eesmith 4y agoYou must surely know that "solving FAANG problems" is greatly overselling the content. It doesn't describe how to solve problems, nothing is FAANG-specific, the introductions at https://wiki.python.org/moin/BeginnersGuide/NonProgrammers https://wiki.python.org/moin/BeginnersGuide/NonProgrammers are more informative, and it's not going to help with any interview, much less a FAANG one. This document assumes the reader will know what O() notation means, and know that `[start, end)` refers to mathematical interval notation instead of Python, and know what a lambda function is. Someone with that experience would gain much more by diving in with https://docs.python.org/3/tutorial/index.html https://docs.python.org/3/tutorial/index.html .
- Pessimist5318 4y agoIt's just a small reference for programmers who already know Python, it does not aim to teach Python or how to solve FAANG problems. It's just a PDF with 11 pages... The Python solutions for leetcode problems surely use something defined in that small reference, so that's what I have listed there.
- Pessimist5318 4y agobtw, >>> 2 * 3 # Equivalent to `pow(2, 3)` is true. At least, that's what I am getting with Python 3.10.2.