Semaphore: Counting and Binary Semaphores
Edsger Dijkstra introduced semaphores in 1965 as one of the first synchronization primitives for concurrent programming. The concept is elegantly simple: a semaphore is an integer counter that…
Read more →Edsger Dijkstra introduced semaphores in 1965 as one of the first synchronization primitives for concurrent programming. The concept is elegantly simple: a semaphore is an integer counter that…
Read more →Counting unique elements sounds trivial until you try it at scale. The naive approach—store every element in a set and count—requires memory proportional to the number of unique elements. For a…
Read more →The Distinct Subsequences problem (LeetCode 115) asks a deceptively simple question: given a source string s and a target string t, count how many distinct subsequences of s equal t.
Standard Bloom filters have a fundamental limitation: they don’t support deletion. When you insert an element, multiple hash functions set several bits to 1. The problem arises because different…
Read more →Every computer science student learns that comparison-based sorting algorithms have a fundamental lower bound of O(n log n). This isn’t a limitation of our creativity—it’s a mathematical certainty…
Read more →