cary61 / LeetCode-Java-Algorithm-Templates

Helps to build your solution faster during leetcode contest, without same old template writing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Java Algorithm Templates

Helps to build your solution faster during leetcode contest, without same old template writing.

About

We can see that so many top rating contestants on LeetCode pasting algorithm templates on their code. Some C++ coders even use macros to reduce the quantity of code that needed to write. To make it fair, I have built and posted these algorithm templates online, for anyone to use.

Info

The algorithm templates I've already written:

Algorithm Status Directory
BFS Versions of with_edges, with_adjacent_array, with_adjacent_list, in_grid. \graph\search
DFS Versions of with_edges, with_adjacent_array,with_adjacent_list, in_grid. \graph\search
Tree Traversal Versions of BFS, DFS, level-order, pre-order, in-order, post-order. \graph\tree\binary_tree
Union Find 1. Standard version. 2. Supporting big amount vertexes, implemented by HashMap version. 3. Supporting any type of variables as vertexes, the generics version. \graph\union_find
Adjacent Difference Standard version. \range\adjacent_difference
Binary Indexed Tree Version of sum. \range\binary_indexed_tree
Prefix Sum Versions of prefix sum and prefix xor-sum, both have linear and 2D sub-versions. \range\prefix_sum
Segment Tree Versions of sum, max, min, xor-sum, product, gcd, lcm, universal. The versions of sum, max, min have special range adding & covering support sub-versions. All implemented by nodes. \range\segment_tree
Rabin Karp (Rolling Hash) 4 Rabin Karp utilities classes, supporting string matching and finding in 3 different ways: calling method by strings themselves, by their hash arrays, by their special instances. The additional one file support all 3 ways. \string\rabin_karp
Trie One standard version supports lower case letters, and one version supports any UTF letters implemented by HashMap. \string\trie
Math GCD (Greatest Common Divisor), LCM(Least Common Multiple), Factorial, Ceiling_Divide. \math

Get Started

All templates are in the folder "Standard". Go get them and read the comments in them, they will guide you to use them.

To get the code of clean version with no comments, see the folder "NoComments". There is same directory structure below, just like they are in "Standard".

This repository aims to let you "Copy and Paste". So in convenience there is no project structure between the java files. All java files have no import declarations, can be copied and pasted in your solution instantly, without any adjustments.

Contributor

(Only me by now)

Cary Zheng

cary61 (Cary61) (github.com)

LeetCode index: cary61 - (LeetCode.cn), and Cary61 - (LeetCode)

Contact me: cary61@gmail.com

About

Helps to build your solution faster during leetcode contest, without same old template writing.

License:GNU General Public License v3.0


Languages

Language:Java 100.0%