Hernando Abella
300+ Python Algorithms

300+ Python Algorithms

Mastering the Art of Problem-Solving

by Hernando Abella

Master Python with 300+ solved algorithms and practical examples.

Inside the book

Build problem-solving skills with Python

A practical collection of 300+ solved algorithms, with explanations and Python examples aimed at helping readers develop a foundation in algorithmic problem solving.

300+

solved algorithms

Python

implementations

Clear guidance

practical explanations

Foundations

algorithms and data structures

Data structures covered in the preview

ArraysLinked listsStacksQueuesTreesGraphsHash tables
Language
English
Publisher
Hernando Abella
ISBN
9798227430816

Sample topics

See the kinds of problems inside

FROM THE PREVIEW
  • 01Equilibrium index in an array
  • 02Find triplets with zero sum
  • 03Convert a 2D array index to 1D
  • 04Find the kth largest element
  • 05Median of two sorted arrays
  • 06Check whether an array is monotonic
  • 07Find pairs with a target sum
  • 08Generate permutations
  • 09Build prefix sums

The sample list is taken from the book preview. It includes array problems and examples of common data structures.

Ready to practice?

Buy the PDF or read the sample before deciding.

Read the preview

Debug slow code

Profile a real function and inspect its bytecode to find bottlenecks.

Why it matters: Use this when an endpoint is slow and you need to see what Python actually executes.

Output: 0.000123 seconds

import dis, timeit

def total(items):
    return sum(items)

print(timeit.timeit(lambda: total(range(1000)), number=1000))
dis.dis(total)

Avoid memory leaks

Track references in a data pipeline to prevent runaway memory.

Why it matters: Useful when processing large batches and memory keeps growing.

Output: 8056 bytes

import sys

batch = [range(1000) for _ in range(1000)]
print(sys.getsizeof(batch))

Ship faster APIs

Use built-ins and C extensions to speed up production endpoints.

Why it matters: Built-ins run in C and avoid Python-level loops.

Output: fast path enabled

def fast_sum(items):
    return sum(items)

# CPython optimizes built-ins

Understand decorators

See how decorators wrap functions at runtime.

Why it matters: Helps debug middleware and logging wrappers.

Output: call

def log(fn):
    def wrapper(*a, **k):
        print('call')
        return fn(*a, **k)
    return wrapper

Inspect objects

Explore object layout and attributes in memory.

Why it matters: Useful when serializing or debugging state.

Output: {}

class User:
    pass

u = User()
print(u.__dict__)

Measure GC

Trigger and observe garbage collection in long jobs.

Why it matters: Prevents memory buildup in long-running workers.

Output: (123, 45, 2)

import gc

gc.collect()
print(gc.get_count())

Call C APIs

Extend Python with native modules for speed.

Why it matters: Useful for performance-critical sections.

Output: <CDLL 'libc.so.6'>

import ctypes

lib = ctypes.CDLL('libc.so.6')
print(lib)

Read source

Navigate CPython source to answer deep questions.

Why it matters: Find the real implementation behind Python features.

Output: # CPython source path

# CPython source: Objects/listobject.c

Build mental model

Know what happens after you press Run.

Why it matters: Makes debugging and optimization intuitive.

Output: Hello, CPython

print('Hello, CPython')

Your place in the path

This book is one piece of the transformation system. Here is how it fits in each career path.

Software ArchitectStage: Foundations · Month 0–3

Master algorithms, data structures and one language in depth.

About the author

Hernando Abella writes practical programming books and tutorials to help developers build real skills, from fundamentals to advanced systems.