PROBLEM DESCRIPTION You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively....
Design Pattern: Flyweight
FLYWEIGHT The Flyweight pattern is a design pattern that helps optimize memory usage by sharing common data between multiple objects. It is particularly useful when dealing with objects that have ...
Design Pattern: Facade
FACADE The Facade design pattern is a structural design pattern that provides a simplified interface to a complex system, making it easier to use. It encapsulates the complexity of the system behi...
Design Pattern: Decorator
DECORATOR Decorator design pattern is a structural design pattern that allows us to add extra features or behaviors to an object without changing its original structure. In this example, we have ...
Design Pattern: Adapter
ADAPTER The Adapter design pattern is a structural design pattern that allows objects with incompatible interfaces to work together. It acts as a bridge between two incompatible interfaces, conver...
Java Multithreading - Interrupting Threads
This following post is based on the Udemy Course: Java Multithreading UNDERSTANDING INTERRUPT USING CODE The main thread pauses for 500 milliseconds (0.5 seconds) using Thread.sleep(500). This ...
Java Multithreading - Callable and Future
This following post is based on the Udemy Course: Java Multithreading CALLABLE AND FUTURE Callable is an interface that represents a task or computation that can be executed in a separate threa...
Java Multithreading - Semaphores
This following post is based on the Udemy Course: Java Multithreading SEMAPHORES A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each acquire() blocks if necessar...
Java Multithreading - Deadlock
This following post is based on the Udemy Course: Java Multithreading DEADLOCK Process 1 Process 2 +-----------------+ +-----------------+ | Resource A | | Resource B |...
Design Pattern: Factory
FACTORY This pattern involves creating two key components: a “product” and a “factory.” In this example, the “product” is the Database interface. It defines the common methods that all types of d...