Skip to content

All the important data structures and algorithms that I use in Competitive Prgramming

Notifications You must be signed in to change notification settings

Kadam-Tushar/Competitive-Programming-in-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Competitive Programming in Java

cp_icon

  • If this repo gave you even a tiny smidge of joy or help, hit it with a shiny star ⭐!

  • This repository contains all the important data structures and algorithms that I use in Competitive Programming.

  • I have cis_pie as my username on all coding platforms. You can view me on Codechef or Codeforces.

  • Feel free to use these codes and let me know if you find any bug.

Links

Data Structures
Algorithms
Strings
Maths related

Miscellaneous

Fast IO for JAVA : Template.

  • Taken this template from legendary coder uwi

  • Java is a little bit slower than C++/C and the main factor behind this is slow console input/output.

  • Java's Scanner, as well as BufferedReader class, is too slow. So the best option is creating your own input-output classes.

  • I had never faced Time Limit Exceed Error (i.e Code takes too much time because of an inefficient/wrong algorithm ) after I started using this template.

  • To use this template you have to write all your code in solve() method.

  • From main() method we are calling solve() method which is supposed to solve the asked problem.

Documentation of methods from this template :

  • INPUT METHODS

    • int x=ni() -to input single number Short form of nextInt()

    • long x=nl() -to input long number nextLong()

    • double x=nd() - to input double values nextDouble()

    • String x=ns() - to input string nextString()

    • char x=nc() - to input character nextChar()

    • int[] arr=na(int n) -to input array of size n i.e parameter is integer with value n. It will allocate a new array and return its reference. nextArray()

    • char [][] matrix =nm(int n,int m) this is method is used tor inputing character matrix nextMatrix()

    • Refer this for inputs which are EOF terminated.

  • OUTPUT METHODS

    • pn(Object o) - method is used to print anthing on console the parameter is Object is you can pass anthing. It is similar as System.out.println().

    • p(Object o)- Similar as System.out.print()

  • UTILITY FUNCTIONS

    • int x=max( int[] arr) -it will find max element from array.

    • int y=min(int [] arr) it will find min element from array.

    • int g=gcd(x,y) for finding gcd.

    • Implemented pair class because there is no inbuilt pair class. You can use the pair in Hashed Collections as well as Tree Collections because hashCode() and compareTo() methods are implemented in this pair class.

About

All the important data structures and algorithms that I use in Competitive Prgramming

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published