Giter Site home page Giter Site logo

shahjalalshohag / code-library Goto Github PK

View Code? Open in Web Editor NEW
2.6K 28.0 698.0 3.46 MB

Templates, algorithms and data structures implemented and collected for programming contests.

License: MIT License

C++ 99.85% Python 0.15%
algorithms code-library data-structures data-structures-and-algorithms hacktoberfest cpp competitive-programming

code-library's Introduction

Contributors Forks Stargazers Issues MIT License LinkedIn

This is my personal code library where I compiled almost all the important templates that you will need in Competitive Programming (saying almost just for courtesy). Most of the codes are originally written by me and some of them are collected from others but modified in a cleaner way.

It took me around 4 years to complete the list. Maybe each line is just a line to you but to me it tells a story of the excitements I had while learning those stuffs, the sleepless but fun nights I had to seek knowledge.

Why am I sharing this library?

  • Just so that your learning path becomes a bit smoother.
  • Knowledge hidden inside my head or codes in a private code-library will be useless when I am dead, so it's better to share those among people before I die.

Also, you can make me happy(as in to pay me) just by giving a star to the repository.

I believe that my coding style is pretty clean and readable, and furthermore, a few problem links are attached to most of the codes so that you can practice those problems. Best wishes, my friend blobheart.

Topic List (For this Library, Must Check)

The topic lists for which I have created this library can be found here. It also contains the relevant problems and tutorials of each topic. Upvote the attached blog if you think I have helped you somehow.

code-library's People

Contributors

defrager avatar fakhrulsojib avatar marcinknapik37 avatar rishab-nahar avatar shahjalalshohag avatar st3inum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

code-library's Issues

Looking for Well Structured and Well Documented Code

Most files do not contain generalized and well-documented codes. For example for the following segment tree code:

struct ST {
  int t[4 * N];
  static const int inf = 1e9;
  ST() {
    memset(t, 0, sizeof t);
  }
  void build(int n, int b, int e) {
    if (b == e) {
      t[n] = a[b];
      return;
    }
    int mid = (b + e) >> 1, l = n << 1, r = l | 1;
    build(l, b, mid);
    build(r, mid + 1, e);
    t[n] = max(t[l], t[r]);
  }
  void upd(int n, int b, int e, int i, int x) {
    if (b > i || e < i) return;
    if (b == e && b == i) {
      t[n] = x;
      return;
    }
    int mid = (b + e) >> 1, l = n << 1, r = l | 1;
    upd(l, b, mid, i, x);
    upd(r, mid + 1, e, i, x);
    t[n] = max(t[l], t[r]);
  }
  int query(int n, int b, int e, int i, int j) {
    if (b > j || e < i) return -inf;
    if (b >= i && e <= j) return t[n];
    int mid = (b + e) >> 1, l = n << 1, r = l | 1;
    int L = query(l, b, mid, i, j);
    int R = query(r, mid + 1, e, i, j);
    return max(L, R);
  }
}t;

A better approach would be:

  • Add template <typename T> before the struct to make it more generalized for any type.
  • Add documentation before every function to explain what the function does.
  • Link to some problems where you have tested this structure.

Example PR: #25

Check the whole codebase, you will be able to find lots of files where you can work on similar stuff.

Contribution Steps:

  1. Identify Areas for Improvement: Scan through the codebase and identify files or components where similar issues can be fixed or optimized.

  2. Fix Issues: Make the necessary changes in a new branch. Ensure that you adhere to the project's coding guidelines and that your changes are well-documented.

  3. Open a Pull Request: After completing your changes, please open a pull request for review.

Once your PR is submitted, it will be reviewed and, if approved, merged into the main branch.

Thank you for your contribution!

I want to add the program for Majority element

##Description

Given an array nums of size n, return the majority element.

The majority element is the element that appears more than โŒŠn / 2โŒ‹ times. You may assume that the majority element always exists in the array.

Dijkstra algorithm

Hey ๐Ÿ‘‹ , I want to add dijkstra algorithm to this repo which useful for finding shortest path from source to destination. Please assign it to me under Hacktoberfest tag
Thank you:)

I want to make a collection of some most useful algorithms codes at one Place

1)K-way merge Algorithm

2)Stack Reduced Quick Sort

3)Merge sort combined with Insertion Sort

4)Prims, Topological, Kruskal's algorithm

5)DijKstra , Floyd Warshall ,bellman ford algorithm

6)Backtracking
a) Rat Maze
b) N-Queen
c) Sudoku
d) Sum of Subset

7)Activity selection , Huffman Encoding

  1. Longest common subsequence , Quick Sort etc

please assign this to me , I am very much Interested to contribute myself in Hacktoberfest_2023 : )

Monotonic MinMaxQueue

My Implementation of monotonic Minimum and Maximum Queue:

template<typename T>
class MinMaxQueue {    
public:
    deque<T> q, minq, maxq;
    
    void push_back(T val) {
        q.push_back(val);
        while(!minq.empty() and minq.back() > val)
            minq.pop_back();
        while(!maxq.empty() and maxq.back() < val) 
            maxq.pop_back();
        minq.push_back(val);
        maxq.push_back(val);
    }
    
    void pop_front() {
        T val = q.front(); q.pop_front();
        if(val == minq.front())
            minq.pop_front();
        if(val == maxq.front())
            maxq.pop_front();
    }
    
    T min() {
        return minq.front();
    }
    
    T max() {
        return maxq.front();
    }
    
    T front() {
        return q.front();
    }  

    int size() {
        return q.size();
    }

    bool empty() {
        return q.empty();
    }
};

Tested it on:
Problem: https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/
My Solution: https://leetcode.com/submissions/detail/792036375/

References:

Bug in Bigint template

The Bigint template fails for multiplication of negative numbers. (Checked on Library checker).

However manually changing to positive and assigning the sign later gives AC.

Adding Backtracking folder

I want to create a new folder which includes all Backtracking problems with codes.

Please assign this to me , I am interested to contribute my self in hacktoberfest_23 : )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.