/just-dsa

Solving the most interesting problems in computer science using the power of data structures and algorithms

Primary LanguageGo

Just-DSA

This project contains various interesting algorithms and data structures implemented in Go.

Arrays and Strings

Contains implementations related to arrays and strings.

  • arrays

    • concatenation-array: Implements concatenation of an array.
    • iterator: Implements an iterator for arrays.
    • longest-consecutive-seq: Finds the length of the longest consecutive sequence in an array.
    • remove-element: Removes an element from an array.
    • zero-matrix: Converts rows and columns to zero in a matrix.
  • strings

    • first-unique-character: Finds the first unique character in a string.
    • interleave-iterator-string: Interleaves characters from two strings using an iterator.
    • string-compression: Compresses a string by replacing consecutive characters with their count.
    • string-rotate: Rotates characters in a string.
    • valid-parenthesis-string: Checks if a string containing '(' and ')' characters is valid.

Backtracking

Implements backtracking algorithms.

  • combination: Generates combinations from a given array.
  • combination-sum: Finds combinations that sum up to a target value.
  • path-sum-tree: Determines if there exists a root-to-leaf path with a given sum in a binary tree.
  • permutation-with-no-duplicates: Generates permutations of a set of unique integers.
  • permutation-of-set: Generates permutations of a set of integers.
  • phone-num-combination: Generates combinations of a phone number.
  • subset-without-duplicates: Generates subsets of a set of unique integers.
  • super-set: Generates the super set of given elements.

Binary Search

Implements binary search algorithms.

  • 2d-binary-search: Performs binary search in a 2D matrix.
  • bad-version: Finds the first bad version in a sequence.
  • binary-search: Performs binary search on a sorted array.
  • guessing-game: Implements a guessing game algorithm.
  • koko-eating-banana: Determines the minimum integer value of k to make the total number of bananas eaten equal to h.

Dynamic Programming

Implements dynamic programming algorithms.

  • 1d: Contains algorithms using 1D dynamic programming.
  • 2d: Contains algorithms using 2D dynamic programming.
  • fixed-knapsack: Solves knapsack problems with fixed capacity.
  • unbounded-knapsack: Solves knapsack problems with unlimited items.

Graph

Implements graph algorithms.

  • advanced: Contains advanced graph algorithms like Bellman-Ford, Dijkstra's, Kruskal's, etc.
  • basic: Contains basic graph algorithms like BFS, DFS, shortest paths, etc.
  • trees: Contains algorithms related to trees and heaps.

Linked List

Contains algorithms and utilities related to linked lists.

  • Various algorithms for linked lists manipulation and operations.

Prefix Sums

Implements algorithms using prefix sum technique.

  • cal-prefix-sum: Calculates prefix sum of an array.
  • find-pivot-idx: Finds the pivot index of an array.
  • no-of-subarr-with-sum-k: Counts the number of contiguous subarrays that sum up to a target value.
  • pdt-of-array-except-self: Calculates product of array except self.

Queue

Implements queue-related algorithms.

  • reconstruction-by-height: Reconstructs the queue based on height and number of taller people ahead.
  • stack-as-queue: Implements a queue using stacks.
  • student-sandwich: Determines if a student can obtain a sandwich in a queue.

Sliding Window

Implements algorithms using sliding window technique.

  • fixed-size: Contains algorithms using fixed-size sliding window.
  • variable-size: Contains algorithms using variable-size sliding window.

Sort

Implements sorting algorithms.

  • insertion-sort: Implements insertion sort algorithm.
  • merge-sort: Implements merge sort algorithm.

Stack

Implements stack-related algorithms.

  • baseball: Calculates the total score in a baseball game.
  • min-stack: Implements a stack that supports push, pop, top, and retrieving the minimum element.
  • valid-parenthesis: Determines if the given string of parentheses is valid.

Time Series

Contains algorithms related to time series data.

  • buy-sell-stock-1: Calculates the maximum profit from buying and selling stocks.
  • buy-sell-stock-2: Calculates the maximum profit from multiple transactions of buying and selling stocks.

Two Pointers

Implements algorithms using two-pointer technique.

  • container-with-most-water: Finds the container with the most water.
  • remove-duplicates: Removes duplicates from a sorted array.
  • remove-duplicates-2: Removes duplicates from a sorted array allowing at most two duplicates.
  • valid-palindrome: Determines if a given string is a valid palindrome.

For detailed explanations and implementation of each algorithm, refer to the respective README files within each directory.