Skip to content

Latest commit

Β 

History

History
40 lines (31 loc) Β· 965 Bytes

File metadata and controls

40 lines (31 loc) Β· 965 Bytes

Coding Patterns in Java

This repository organizes common coding patterns used to solve algorithmic problems efficiently.

Patterns Covered

  • Two Pointers
  • Sliding Window
  • Fast and Slow Pointers
  • Merge Intervals
  • Cyclic Sort
  • In-place Reversal of Linked List
  • Depth-First Search (DFS)
  • Breadth-First Search (BFS)
  • Topological Sort
  • Binary Search
  • Dynamic Programming
  • Backtracking
  • Bit Manipulation
  • Greedy
  • Subsets/Combinations/Permutations

πŸ“Œ Two Pointers

The Two Pointers pattern is used when dealing with sorted arrays or linked lists to find a pair, triplet, or subarray that meets certain criteria (e.g., sum, length, duplicates).

Common Use Cases:

  • Pair with target sum
  • Remove duplicates
  • Reverse an array in-place
  • Compare strings/arrays (anagram, palindrome)

Example Problems:

  • Reverse Array
  • Two Sum II – Input array is sorted
  • Remove Duplicates from Sorted Array
  • Is Subsequence