Implement a type-safe Last-In-First-Out (LIFO) Stack data structure in TypeScript with full generic parameterization and peek/pop protections.
When this program is compiled and executed, the terminal outputs:
Top element: 30 Popped: 30 Stack size: 2 Last action: EDIT_CODE
Practice in our high-performance cloud container IDE with multi-file support, interactive terminal STDIN, real-time memory visualizer, and structured lessons.
Implement a Least Recently Used (LRU) Cache in TypeScript using a Map data structure to achieve O(1) get and put operations with type safety.
A prime number is a positive integer greater than 1 that has no positive divisors other than 1 and itself. This example demonstrates an optimized approach checking factors up to √n.
The Fibonacci sequence is a series where each number is the sum of the two preceding ones, starting from 0 and 1. Here we implement iterative generation and generator streaming.