# Dirichlet Convolution And Mobius: Practice Notes

Dirichlet Convolution And Mobius shows up often in coding rounds. Here is how I talk through it when the interviewer is watching.

## Key idea

The Dirichlet convolution of 1 and μ is ε, so prefix sums of multiplicative f can be inverted against prefix sums of 1 or id through Möbius inversion.

## Steps to say out loud

1. Restate the input and the exact ask, and nail down constraints and overflow.
2. Name the pattern (binary search on the answer, monotonic stack or deque, interval / interval-DP, string hashing, graph traversal, or shortest paths) and why a nested scan or naive search fails.
3. Code it, then trace a short example plus one empty or already-solved edge case.

## Complexity

O(n) to tabulate μ, then the usual inversion cost.

## Common mistake

Convolving with μ without the multiplicative identity check, which inverts the wrong function.

## Practice tip

Time yourself: two minutes to explain, ten to code, three to test edges. Disclosure: I work on Linkjob AI. I also keep a practice cheat sheet at AI help for online coding assessments.