We have translated repo with huge list of things to learn into Uzbek, for Interview preparation for giants such as : Amazon, Facebook, Google, and Microsoft.
https://github.com/jwasham/coding-interview-university/blob/main/translations/README-uz.md
share with your friends )
https://github.com/jwasham/coding-interview-university/blob/main/translations/README-uz.md
share with your friends )
GitHub
coding-interview-university/translations/README-uz.md at main · jwasham/coding-interview-university
A complete computer science study plan to become a software engineer. - jwasham/coding-interview-university
#Deque
A deque (double-ended queue), from collections library, has the feature of adding and removing elements from either end(source). It is preferred over list in the cases where we need quicker append and pop operations from both the ends of container, as deque provides an O(1) time complexity for append and pop operations as compared to list which provides O(n) time complexity (source).
A deque (double-ended queue), from collections library, has the feature of adding and removing elements from either end(source). It is preferred over list in the cases where we need quicker append and pop operations from both the ends of container, as deque provides an O(1) time complexity for append and pop operations as compared to list which provides O(n) time complexity (source).
#Deque_continue
deque(maxlen=N) creates a fixed-sized queue. When new items are added and the queue is full, the oldest item is automatically removed. (Source: "Python Cookbook")
deque(maxlen=N) creates a fixed-sized queue. When new items are added and the queue is full, the oldest item is automatically removed. (Source: "Python Cookbook")
#SubArray, #SubSequence, #SubSet
Comparing SubArray SubSequence and SubSet
✅ Subarray is contiguous sequence in an array.
e.g we have an array of {1, 2, 3, 4}
subarray can be: {1,2,3}, {2,3,4}, {1,2} etc.
✅ A subsequence doesn't need to be contiguous, but maintains order
e.g subsequence can be: {1, 2, 4} {2, 4} {1, 3, 4} etc.
✅ A subset doesn’t need to maintain order and has non-contiguous behavior.
e.g subset can be: {4, 1,3} {3, 1, 2 } etc.
Comparing SubArray SubSequence and SubSet
✅ Subarray is contiguous sequence in an array.
e.g we have an array of {1, 2, 3, 4}
subarray can be: {1,2,3}, {2,3,4}, {1,2} etc.
✅ A subsequence doesn't need to be contiguous, but maintains order
e.g subsequence can be: {1, 2, 4} {2, 4} {1, 3, 4} etc.
✅ A subset doesn’t need to maintain order and has non-contiguous behavior.
e.g subset can be: {4, 1,3} {3, 1, 2 } etc.
sort() with sorted()
the sort() function will modify the list it is called on. The sorted() function will create a new list containing a sorted version of the list it is given.
the sort() function will modify the list it is called on. The sorted() function will create a new list containing a sorted version of the list it is given.
#heapq
Title: heapq
The most important feature of a heap is that heap[0] is always the smallest item.
heapq.heappop()-pops off the first item and replaces it with the next smallest item (an operation that
requires O(log N) operations where N is the size of the heap)
source: Python cookbook
Title: heapq
The most important feature of a heap is that heap[0] is always the smallest item.
heapq.heappop()-pops off the first item and replaces it with the next smallest item (an operation that
requires O(log N) operations where N is the size of the heap)
source: Python cookbook
#dicts
Title: Calculating dicts
Title: Calculating dicts
prices = {Get min from dict:
'ACME': 45.23,
'AAPL': 612.78,
'IBM': 205.55,
'HPQ': 37.20,
'FB': 10.75
}
min_price = min(zip(prices.values(), prices.keys()))Get max from dict
# min_price is (10.75, 'FB')
max_price = max(zip(prices.values(), prices.keys()))Sort Dict:
# max_price is (612.78, 'AAPL')
prices_sorted = sorted(zip(prices.values(), prices.keys()))
📌 be aware that zip() creates an iterator that can only be consumed once. If you call zip variable next time, it will return empty obj.#dicts
Title: Comparing dictionaries
Dictionary keys() and items() support common set operations such as unions, intersections, and differences.
values() method of a dictionary does not support the set operations, therefore we cannot perform those operations with dictionary values.
Source: Python Cookbook
Title: Comparing dictionaries
Dictionary keys() and items() support common set operations such as unions, intersections, and differences.
values() method of a dictionary does not support the set operations, therefore we cannot perform those operations with dictionary values.
Source: Python Cookbook
Transforming and reducing data
To calculate the sum of
squares, do the following:
To calculate the sum of
squares, do the following:
nums = [1, 2, 3, 4, 5]
s = sum(x * x for x in nums)
instead of:s = sum((x * x for x in nums))
or
s = sum([x * x for x in nums])
It introduces an extra step and creates an extra list or tuple.
Source: Python cookbook#class #methods
Title:
—The
! A good example is provided above
source: "Python Cookbook:
Title:
__repr__
with __str__
—When we call Class it is represented by __str__
method by default, if there is not __str__
method, __repr__
() method will be called.—The
__repr__()
method returns the code representation of an instance, The __str__()
method converts the instance to a string! A good example is provided above
source: "Python Cookbook:
#memory_management
Title: String interning
To alleviate memory that can be quickly consumed by strings, Python implements string interning
— A string will be interned if it is a compile-time constant, is not the production of constant folding or is not longer than 20 characters, and consists exclusively of ASCII letters, digits, or underscores.
—Empty strings are interned.
Source
Title: String interning
To alleviate memory that can be quickly consumed by strings, Python implements string interning
— A string will be interned if it is a compile-time constant, is not the production of constant folding or is not longer than 20 characters, and consists exclusively of ASCII letters, digits, or underscores.
—Empty strings are interned.
Source
Title: Namespaces
A namespace is a system that has a unique name for each and every object in Python. An object might be a variable or a method.
There are 3 types of namespaces:
built-in namespaces
global namespaces
local namespaces
e.g
A namespace is a system that has a unique name for each and every object in Python. An object might be a variable or a method.
There are 3 types of namespaces:
built-in namespaces
global namespaces
local namespaces
e.g
var1 = 5 # global namespace
def some_func():
var2 = 6
# local namespace
The built-in namespace is always available when Python is running. You can list all built-in namespaces with dir(__builtins__)
Source