The Sieve of Eratosthenes Part 1: efficiently generating primes up to n
The Sieve of Eratosthenes is an algorithm for finding prime numbers in a range. Conceptually, it's a very simple algorithm. Let's assume our range is always [2, n]. In our examples, we'll consider n=100.
ACM题解系列之 - 最小堆栈 (Min Stack) - Design a Stack with constant time in Push, Pop and Min
Implement a stack with min() function, which will return the smallest number in the stack. It should support push, pop and min operation all in O(1) cost. class MinStack { public: MinStack() { // write
Data Structures in Python - Part 2 - Queues
Queues in Python A Queue A queue is another of the standard data structures that we find throughout Computer Science. Unlike the stack, the queue is a FIFO structure (First In First Out). The items which