Code Monkey home page Code Monkey logo

cp_snippets's Introduction

CP_Snippets

A One Stop Place to find many useful Snippets for competetive programming

Contribution Procedure

  • Raise an issue about the snippet you want to make in the following format: File Name: YourFileName.xx (PascalCase name is compulsory, Example) Description: 2 to 5 lines of what the snippets performs
  • You will be assigned the issue, Then You can create a Pull Request Whose code follows the conduct belo
  • your Snippet should be short and formatted, use minimal boilerplate, and use the format giver below
  • Don't Forget to include your username, Description of code and Date of creation of your code

Example Filename: PrimeCheck.cpp Snippet:

/* 
------------------------------------------------------------------------------------------------
USERNAME: RASESH2005
DESCRIPTION: THIS PROGRAM CHECKS IF A NUMBER IS PRIME OR NOT
DATE: 1/10/2021
------------------------------------------------------------------------------------------------
*/
#include <bits/stdc++.h>

using namespace std;

//SNIPPET
bool isPrime(int n)
{
    for (int i = 2; i <= int(sqrt(n) + 1); i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}
int main()
{
    //APPLICATION
    bool result = isPrime(24498757);
    cout << result << endl;
    cout << (result ? "Prime" : "Not A Prime") << endl;
    return 0;
}
  • Drop the file in the respective language folder, If your language folder is absent make a new folder with your language name
  • Make a PR Addressing the issue you made That was assigned to you.
  • You will receive a response soon

Thank You for contributing

Thank You

cp_snippets's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cp_snippets's Issues

Binary search python snippet

The filename will be: BinarySearch.py
language: python
Description:
A function that returns the index of an element in an array using the binary search method. If the element is not present, -1 is returned.

FindOddlyRepeatedElement.cpp

A C++ program that outputs the number that is repeated odd number of times in an array. The algorithm has O(n) time complexity and O(1) space complexity.

Adding a program to implement stack operations using Linked Lists in C

What is Stack? ๐Ÿ’ป

A Stack is a linear data structure that follows the LIFO (Last-In-First-Out) principle.

What does the program do? ๐Ÿค”

This program will do the following tasks:

  • ๐Ÿ”ผ Push - Insert element at the top of the list
  • ๐Ÿ”ฝ Pop - Delete element at the top of the list
  • ๐Ÿ–จ๏ธ Display Stack Top - Display the element on the top of stack
  • โ›” Exit - Quit the user defined loop

FindOddlyRepeatedElement.cpp

A C++ program that outputs the number that is repeated odd number of times in an array. The algorithm has O(n) time complexity and O(1) space complexity.

Adding BST from Preorder Traversal

I want to add the program for: Given an array of integers which represents the preorder traversal of a Binary Search Tree . Construct the BST and return its root.
Please assign me this.

SwapTwoVariables.cpp

In this C++ Programming, we will perform Swapping of 2 Variables using 3rd Variable in C++. The third variable will act as a temporary variable to perform the swapping.

Add Prime Sieve Snippet

File name: PrimeSieve.cpp
Language: C++
Description:
C++ program to print all primes smaller than or equal to n using Sieve of Eratosthenes

QuickSort.c

The following code snippet performs Quick Sort on an array of numbers

Adding program to rotate the array.

Adding program for left rotation of array. (shifting of the elements in an array towards the left) in C++
Please assign this to me.
Thank you!

SortArrayIn0s_1s_2s.cpp

Hello
I want to add Dutch Flag algorithm to solve this problem .
Please assign this task to me.

InsertionSort.c

The snippet sorts an array of number using Insertion Sort

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.