Skip to content

Latest commit

 

History

History
117 lines (67 loc) · 6.47 KB

coding_patterns.md

File metadata and controls

117 lines (67 loc) · 6.47 KB

Coding Interview Patterns

✅ Dynamic Programming Patterns: https://lnkd.in/gVNgiDWH

✅ Tree Patterns: https://lnkd.in/gYB7zUX6

✅ Graph Patterns: https://lnkd.in/geZGw4Vt

✅ Substring Problem Patterns: https://lnkd.in/gt23kRen

✅ Backtracking Problem Pattern: https://lnkd.in/gk6JqQD4

✅Two Pointers Patterns: https://lnkd.in/gfea3T9v

✅ Binary Search Patterns: https://lnkd.in/gHhq5MrR

✅ Cloning Problems Patterns: https://lnkd.in/gJWqTDV8

✅ Bit Manipulation Pattern: https://lnkd.in/gE6cdc-g

✅ Heap Patterns: https://lnkd.in/gugVTJsT

✅ Sliding Window Patterns: https://lnkd.in/gb5NeskQ

Design Patterns

There are three types of Design Patterns:

➤ Creational Design Pattern

➤ Structural Design Pattern

➤ Behavioral Design Pattern

Check out the Software Design Patterns tutorial here

Creational

Factory Method Pattern: Implementation

The Factory Method pattern is used to create objects without specifying the exact class of object that will be created. This pattern is useful when you need to decouple the creation of an object from its implementation.

Singleton Pattern: Implementation

The Singleton method or Singleton Design pattern is one of the simplest design patterns. It ensures a class only has one instance, and provides a global point of access to it.

Builder Pattern: Implementation

Builder pattern aims to “Separate the construction of a complex object from its representation so that the same construction process can create different representations.” It is used to construct a complex object step by step and the final step will return the object.

Prototype Pattern: Implementation

Prototype allows us to hide the complexity of making new instances from the client. The concept is to copy an existing object rather than creating a new instance from scratch, something that may include costly operations. The existing object acts as a prototype and contains the state of the object.

Abstract Pattern: Implementation

Abstract Factory pattern is almost similar to Factory Pattern and is considered as another layer of abstraction over factory pattern. Abstract Factory patterns work around a super- factory which creates other factories.

Structural

Adapter Pattern: Implementation

The adapter pattern convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.

Decorator Pattern: Implementation

It allows us to dynamically add functionality and behavior to an object without affecting the behavior of other existing objects within the same class. We use inheritance to extend the behavior of the class. This takes place at compile-time, and all the instances of that class get the extended behavior.

Facade Pattern: Implementation

Facade Method Design Pattern provides a unified interface to a set of interfaces in a subsystem. Facade defines a high-level interface that makes the subsystem easier to use.

Behavioral

Observer Pattern: Implementation

It defines a one-to-many dependency between objects, so that when one object (the subject) changes its state, all its dependents (observers) are notified and updated automatically.

State Pattern: Implementation

A state design pattern is used when an Object changes its behavior based on its internal state. If we have to change the behavior of an object based on its state, we can have a state variable in the Object and use the if-else condition block to perform different actions based on the state.

Strategy Pattern: Implementation

The Strategy Design Pattern allows the behavior of an object to be selected at runtime. It is one of the Gang of Four (GoF) design patterns, which are widely used in object-oriented programming. The Strategy pattern is based on the idea of encapsulating a family of algorithms into separate classes that implement a common interface.

Data Structures

  1. Design Dynamic Array (Resizable Array): https://lnkd.in/gydhM-Cy
  2. Design Singly Linked List: https://lnkd.in/gDMR_EGP
  3. Design Double-ended Queue: https://lnkd.in/gYtRfTzQ
  4. Design Binary Search Tree: https://lnkd.in/gvr8hHH5
  5. Design Hash Table: https://lnkd.in/gxJVHs-4
  6. Design Heap: https://lnkd.in/gx2xiRZS
  7. Design Graph: https://lnkd.in/gnZcMYuE
  8. Design Disjoint Set (Union-Find): https://lnkd.in/gpqc-hps
  9. Design Segment Tree: https://lnkd.in/gBZUKiVn

Sorting

  1. Insertion Sort: https://lnkd.in/gW7zWpyq
  2. Merge Sort: https://lnkd.in/gHD6KS8e
  3. Quick Sort: https://lnkd.in/gnUP6qRh

Algorithms

  1. Matrix Depth-First Search: https://lnkd.in/gvTZKSGy
  2. Matrix Breadth-First Search: https://lnkd.in/g-T2Rh_E
  3. Dijkstra's Algorithm: https://lnkd.in/gnK-YYxM
  4. Prim's Algorithm: https://lnkd.in/gif8fCKq
  5. Kruskal's Algorithm: https://lnkd.in/gfEMwsmp
  6. Topological Sort: https://lnkd.in/gW8hV4Mv

Knapsack Problems

  1. 0/1 Knapsack: https://lnkd.in/gYuw8-8c
  2. Unbounded Knapsack: https://lnkd.in/gxzTRwcD